Ajout et config du module Chronopost

This commit is contained in:
2021-09-22 23:03:39 +02:00
parent 7287fb7959
commit 08f1af5f96
60 changed files with 13945 additions and 18 deletions

View File

@@ -0,0 +1,71 @@
<?php
namespace ChronopostHomeDelivery\Loop;
use ChronopostHomeDelivery\Model\ChronopostHomeDeliveryPrice;
use ChronopostHomeDelivery\Model\ChronopostHomeDeliveryPriceQuery;
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 ChronopostHomeDeliveryLoop
* @package ChronopostHomeDelivery\Loop
*
* @method integer getAreaId
* @method integer getDeliveryModeId
*/
class ChronopostHomeDeliveryLoop 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)
);
}
/**
* @return ChronopostHomeDeliveryPriceQuery|\Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$areaId = $this->getAreaId();
$modeId = $this->getDeliveryModeId();
$areaPrices = ChronopostHomeDeliveryPriceQuery::create()
->filterByDeliveryModeId($modeId)
->filterByAreaId($areaId)
->orderByWeightMax();
return $areaPrices;
}
/**
* @param LoopResult $loopResult
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var ChronopostHomeDeliveryPrice $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;
}
}