Commit du module Colissimo
This commit is contained in:
58
local/modules/SoColissimo/Loop/AreaFreeshippingDom.php
Normal file
58
local/modules/SoColissimo/Loop/AreaFreeshippingDom.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\Model\SocolissimoAreaFreeshippingDomQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class AreaFreeshippingDom extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('area_id'),
|
||||
Argument::createIntTypeArgument('delivery_mode_id')
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$areaId = $this->getAreaId();
|
||||
$mode = $this->getDeliveryModeId();
|
||||
|
||||
$modes = SocolissimoAreaFreeshippingDomQuery::create();
|
||||
|
||||
if (null !== $mode) {
|
||||
$modes->filterByDeliveryModeId($mode);
|
||||
}
|
||||
|
||||
if (null !== $areaId) {
|
||||
$modes->filterByAreaId($areaId);
|
||||
}
|
||||
|
||||
return $modes;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \SoColissimo\Model\SocolissimoAreaFreeshippingDom $mode */
|
||||
foreach ($loopResult->getResultDataCollection() as $mode) {
|
||||
$loopResultRow = new LoopResultRow($mode);
|
||||
$loopResultRow->set("ID", $mode->getId())
|
||||
->set("AREA_ID", $mode->getAreaId())
|
||||
->set("DELIVERY_MODE_ID", $mode->getDeliveryModeId())
|
||||
->set("CART_AMOUNT", $mode->getCartAmount());
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
58
local/modules/SoColissimo/Loop/AreaFreeshippingPr.php
Normal file
58
local/modules/SoColissimo/Loop/AreaFreeshippingPr.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\Model\SocolissimoAreaFreeshippingPrQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class AreaFreeshippingPr extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('area_id'),
|
||||
Argument::createIntTypeArgument('delivery_mode_id')
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$areaId = $this->getAreaId();
|
||||
$mode = $this->getDeliveryModeId();
|
||||
|
||||
$modes = SocolissimoAreaFreeshippingPrQuery::create();
|
||||
|
||||
if (null !== $mode) {
|
||||
$modes->filterByDeliveryModeId($mode);
|
||||
}
|
||||
|
||||
if (null !== $areaId) {
|
||||
$modes->filterByAreaId($areaId);
|
||||
}
|
||||
|
||||
return $modes;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \SoColissimo\Model\SocolissimoAreaFreeshippingPr $mode */
|
||||
foreach ($loopResult->getResultDataCollection() as $mode) {
|
||||
$loopResultRow = new LoopResultRow($mode);
|
||||
$loopResultRow->set("ID", $mode->getId())
|
||||
->set("AREA_ID", $mode->getAreaId())
|
||||
->set("DELIVERY_MODE_ID", $mode->getDeliveryModeId())
|
||||
->set("CART_AMOUNT", $mode->getCartAmount());
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
76
local/modules/SoColissimo/Loop/CheckRightsLoop.php
Normal file
76
local/modules/SoColissimo/Loop/CheckRightsLoop.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class CheckRightsLoop
|
||||
* @package Colissimo\Looop
|
||||
* @author Thelia <info@thelia.net>
|
||||
*/
|
||||
|
||||
class CheckRightsLoop extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
|
||||
public function buildArray()
|
||||
{
|
||||
$ret = array();
|
||||
$dir = __DIR__."/../Config/";
|
||||
if (!is_readable($dir)) {
|
||||
$ret[] = array("ERRMES"=>Translator::getInstance()->trans("Can't read Config directory"), "ERRFILE"=>"");
|
||||
}
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (strlen($file) > 5 && substr($file, -5) === ".json") {
|
||||
if (!is_readable($dir.$file)) {
|
||||
$ret[] = array("ERRMES"=>Translator::getInstance()->trans("Can't read file"), "ERRFILE"=>"Colissimo/Config/".$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $arr) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ERRMES", $arr["ERRMES"])
|
||||
->set("ERRFILE", $arr["ERRFILE"]);
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
178
local/modules/SoColissimo/Loop/GetRelais.php
Normal file
178
local/modules/SoColissimo/Loop/GetRelais.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\SoColissimo;
|
||||
use SoColissimo\WebService\FindByAddress;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
|
||||
/**
|
||||
* Class GetRelais
|
||||
* @package SoColissimo\Loop
|
||||
* @author Thelia <info@thelia.net>
|
||||
*/
|
||||
class GetRelais extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return array|mixed
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function buildArray()
|
||||
{
|
||||
// Find the address ... To find ! \m/
|
||||
$zipcode = $this->getZipcode();
|
||||
$city = $this->getCity();
|
||||
$countryId = $this->getCountryid();
|
||||
|
||||
$addressId = $this->getAddress();
|
||||
|
||||
if (!empty($addressId) && (!empty($zipcode) || !empty($city))) {
|
||||
throw new \InvalidArgumentException(
|
||||
"Cannot have argument 'address' and 'zipcode' or 'city' at the same time."
|
||||
);
|
||||
}
|
||||
|
||||
if (null !== $addressModel = AddressQuery::create()->findPk($addressId)) {
|
||||
$address = array(
|
||||
"zipcode" => $addressModel->getZipcode(),
|
||||
"city" => $addressModel->getCity(),
|
||||
"address" => $addressModel->getAddress1(),
|
||||
"countrycode"=> $addressModel->getCountry()->getIsoalpha2()
|
||||
);
|
||||
} elseif (empty($zipcode) || empty($city)) {
|
||||
$search = AddressQuery::create();
|
||||
|
||||
$customer = $this->securityContext->getCustomerUser();
|
||||
if ($customer !== null) {
|
||||
$search->filterByCustomerId($customer->getId());
|
||||
$search->filterByIsDefault("1");
|
||||
} else {
|
||||
throw new \ErrorException("Customer not connected.");
|
||||
}
|
||||
|
||||
$search = $search->findOne();
|
||||
$address["zipcode"] = $search->getZipcode();
|
||||
$address["city"] = $search->getCity();
|
||||
$address["address"] = $search->getAddress1();
|
||||
$address["countrycode"] = $search->getCountry()->getIsoalpha2();
|
||||
} else {
|
||||
$address = array(
|
||||
"zipcode" => $zipcode,
|
||||
"city" => $city,
|
||||
"address" => "",
|
||||
"countrycode" => CountryQuery::create()
|
||||
->findOneById($countryId)
|
||||
->getIsoalpha2()
|
||||
);
|
||||
}
|
||||
|
||||
// Then ask the Web Service
|
||||
$request = new FindByAddress();
|
||||
$request
|
||||
->setAddress($address["address"])
|
||||
->setZipCode($address["zipcode"])
|
||||
->setCity($address["city"])
|
||||
->setCountryCode($address["countrycode"])
|
||||
->setFilterRelay("1")
|
||||
->setRequestId(md5(microtime()))
|
||||
->setLang("FR")
|
||||
->setOptionInter("1")
|
||||
->setShippingDate(date("d/m/Y"))
|
||||
->setAccountNumber(ConfigQuery::read('socolissimo_login'))
|
||||
->setPassword(ConfigQuery::read('socolissimo_pwd'))
|
||||
;
|
||||
|
||||
try {
|
||||
$response = $request->exec();
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$response = array();
|
||||
} catch (\SoapFault $e) {
|
||||
$response = array();
|
||||
}
|
||||
|
||||
if (!is_array($response) && $response !== null) {
|
||||
$newResponse[] = $response;
|
||||
$response = $newResponse;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $item) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
//Tlog::getInstance()->addDebug(print_r($item, true));
|
||||
foreach ($item as $key => $value) {
|
||||
$loopResultRow->set($key, $value);
|
||||
}
|
||||
|
||||
// format distance
|
||||
$distance = (string) $loopResultRow->get("distanceEnMetre");
|
||||
if (strlen($distance) < 4) {
|
||||
$distance .= " m";
|
||||
} else {
|
||||
$distance = (string) floatval($distance) / 1000;
|
||||
while (substr($distance, strlen($distance) - 1, 1) == "0") {
|
||||
$distance = substr($distance, 0, strlen($distance) - 1);
|
||||
}
|
||||
$distance = str_replace(".", ",", $distance) . " km";
|
||||
}
|
||||
$loopResultRow->set('distance', $distance);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument("countryid", ""),
|
||||
Argument::createAnyTypeArgument("zipcode", ""),
|
||||
Argument::createAnyTypeArgument("city", ""),
|
||||
Argument::createIntTypeArgument("address")
|
||||
);
|
||||
}
|
||||
}
|
||||
75
local/modules/SoColissimo/Loop/NotSentOrders.php
Normal file
75
local/modules/SoColissimo/Loop/NotSentOrders.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use SoColissimo\SoColissimo;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Core\Template\Loop\Order;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
|
||||
/**
|
||||
* Class NotSentOrders
|
||||
* @package SoColissimo\Loop
|
||||
* @author Thelia <info@thelia.net>
|
||||
*/
|
||||
class NotSentOrders extends Order
|
||||
{
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(Argument::createBooleanTypeArgument('with_prev_next_info', false));
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$status = OrderStatusQuery::create()
|
||||
->filterByCode(
|
||||
array(
|
||||
OrderStatus::CODE_PAID,
|
||||
OrderStatus::CODE_PROCESSING,
|
||||
),
|
||||
Criteria::IN
|
||||
)
|
||||
->find()
|
||||
->toArray("code");
|
||||
$query = OrderQuery::create()
|
||||
->filterByDeliveryModuleId(SoColissimo::getModCode())
|
||||
->filterByStatusId(
|
||||
array(
|
||||
$status[OrderStatus::CODE_PAID]['Id'],
|
||||
$status[OrderStatus::CODE_PROCESSING]['Id']),
|
||||
Criteria::IN
|
||||
);
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
78
local/modules/SoColissimo/Loop/SoColissimoAddress.php
Normal file
78
local/modules/SoColissimo/Loop/SoColissimoAddress.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\Model\AddressSocolissimoQuery;
|
||||
use Thelia\Core\Template\Loop\Address;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
/**
|
||||
* Class SoColissimoDelivery
|
||||
* @package SoColissimo\Loop
|
||||
* @author Thelia <info@thelia.net>
|
||||
*/
|
||||
class SoColissimoAddress extends Address
|
||||
{
|
||||
protected $exists = false;
|
||||
protected $timestampable = false;
|
||||
|
||||
protected function setExists($id)
|
||||
{
|
||||
$this->exists = AddressSocolissimoQuery::create()->findPK($id) !== null;
|
||||
}
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$id = $this->getId();
|
||||
$this->setExists($id[0]);
|
||||
|
||||
return $this->exists ?
|
||||
AddressSoColissimoQuery::create()->filterById($id[0]) :
|
||||
parent::buildModelCriteria();
|
||||
}
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
if (!$this->exists) {
|
||||
return parent::parseResults($loopResult);
|
||||
} else {
|
||||
/** @var \SoColissimo\Model\AddressSocolissimo $address */
|
||||
foreach ($loopResult->getResultDataCollection() as $address) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("TITLE", $address->getTitleId())
|
||||
->set("COMPANY", $address->getCompany())
|
||||
->set("FIRSTNAME", $address->getFirstname())
|
||||
->set("LASTNAME", $address->getLastname())
|
||||
->set("ADDRESS1", $address->getAddress1())
|
||||
->set("ADDRESS2", $address->getAddress2())
|
||||
->set("ADDRESS3", $address->getAddress3())
|
||||
->set("ZIPCODE", $address->getZipcode())
|
||||
->set("CITY", $address->getCity())
|
||||
->set("COUNTRY", $address->getCountryId())
|
||||
->set("CELLPHONE", $address->getCellphone())
|
||||
; $loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
local/modules/SoColissimo/Loop/SoColissimoDeliveryMode.php
Normal file
53
local/modules/SoColissimo/Loop/SoColissimoDeliveryMode.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\Model\SocolissimoDeliveryModeQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class SoColissimoDeliveryMode extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('id')
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$mode = $this->getId();
|
||||
|
||||
$modes = SocolissimoDeliveryModeQuery::create();
|
||||
|
||||
if (null !== $mode) {
|
||||
$modes->filterById($mode);
|
||||
}
|
||||
|
||||
return $modes;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \SoColissimo\Model\SocolissimoDeliveryMode $mode */
|
||||
foreach ($loopResult->getResultDataCollection() as $mode) {
|
||||
$loopResultRow = new LoopResultRow($mode);
|
||||
$loopResultRow->set("ID", $mode->getId())
|
||||
->set("TITLE", $mode->getTitle())
|
||||
->set("CODE", $mode->getCode())
|
||||
->set("FREESHIPPING_ACTIVE", $mode->getFreeshippingActive())
|
||||
->set("FREESHIPPING_FROM", $mode->getFreeshippingFrom());
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
71
local/modules/SoColissimo/Loop/SoColissimoId.php
Normal file
71
local/modules/SoColissimo/Loop/SoColissimoId.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
use SoColissimo\SoColissimo;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
/**
|
||||
* Class SoColissimoId
|
||||
* @package SoColissimo\Loop
|
||||
* @author Thelia <info@thelia.net>
|
||||
*/
|
||||
class SoColissimoId extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* this method returns an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function buildArray()
|
||||
{
|
||||
return array(SoColissimo::getModCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $id) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResult->addRow(
|
||||
$loopResultRow->set('MODULE_ID', $id)
|
||||
);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\Model\OrderAddressSocolissimo;
|
||||
use SoColissimo\Model\OrderAddressSocolissimoQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class SoColissimoOrderAddressLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* Definition of loop arguments
|
||||
*
|
||||
* example :
|
||||
*
|
||||
* public function getArgDefinitions()
|
||||
* {
|
||||
* return new ArgumentCollection(
|
||||
*
|
||||
* Argument::createIntListTypeArgument('id'),
|
||||
* new Argument(
|
||||
* 'ref',
|
||||
* new TypeCollection(
|
||||
* new Type\AlphaNumStringListType()
|
||||
* )
|
||||
* ),
|
||||
* Argument::createIntListTypeArgument('category'),
|
||||
* Argument::createBooleanTypeArgument('new'),
|
||||
* ...
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('id', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$query = OrderAddressSocolissimoQuery::create();
|
||||
|
||||
if (!is_null($id = $this->getId())) {
|
||||
$query->filterById(intval($id));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var OrderAddressSocolissimo $orderAddressSocolissimo */
|
||||
foreach ($loopResult->getResultDataCollection() as $orderAddressSocolissimo) {
|
||||
$row = new LoopResultRow();
|
||||
$row->set('ID', $orderAddressSocolissimo->getId());
|
||||
$row->set('CODE', $orderAddressSocolissimo->getCode());
|
||||
$row->set('TYPE', $orderAddressSocolissimo->getType());
|
||||
$loopResult->addRow($row);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
55
local/modules/SoColissimo/Loop/SoColissimoPrice.php
Normal file
55
local/modules/SoColissimo/Loop/SoColissimoPrice.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace SoColissimo\Loop;
|
||||
|
||||
use SoColissimo\Model\SocolissimoPriceQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class SoColissimoPrice extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('area_id', null, true),
|
||||
Argument::createIntTypeArgument('delivery_mode_id', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$areaId = $this->getAreaId();
|
||||
$modeId = $this->getDeliveryModeId();
|
||||
|
||||
$areaPrices = SocolissimoPriceQuery::create()
|
||||
->filterByDeliveryModeId($modeId)
|
||||
->filterByAreaId($areaId)
|
||||
->orderByWeightMax();
|
||||
|
||||
return $areaPrices;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \SoColissimo\Model\SocolissimoPrice $price */
|
||||
foreach ($loopResult->getResultDataCollection() as $price) {
|
||||
$loopResultRow = new LoopResultRow($price);
|
||||
$loopResultRow
|
||||
->set("SLICE_ID", $price->getId())
|
||||
->set("MAX_WEIGHT", $price->getWeightMax())
|
||||
->set("MAX_PRICE", $price->getPriceMax())
|
||||
->set("PRICE", $price->getPrice())
|
||||
->set("FRANCO", $price->getFrancoMinPrice())
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user