- Nexxpix - OpenStudio * @method getProductId() * @method getQuantity() */ class DigressiveLoop extends BaseI18nLoop implements PropelSearchLoopInterface { public $countable = true; protected function getArgDefinitions() { return new ArgumentCollection( Argument::createIntTypeArgument('product_id'), Argument::createIntTypeArgument('quantity'), Argument::createBooleanTypeArgument('order') ); } public function buildModelCriteria() { $productId = $this->getProductId(); $search = DigressivePriceQuery::create(); if (!is_null($productId)) { $search->filterByProductId($productId); } if (null !== $quantity = $this->getQuantity()) { $search ->filterByQuantityFrom($quantity, Criteria::LESS_EQUAL) ->filterByQuantityTo($quantity, Criteria::GREATER_EQUAL) ; } // TheCoreDev : rajout d'un tri sur la quantité $order = $this->getOrder(); if (!is_null($order)) { switch ($order) { case true : $search->orderByQuantityFrom(); break; case false : $search->orderByQuantityFrom(Criteria::DESC); break; } } return $search; } public function parseResults(LoopResult $loopResult) { /** @var DigressivePrice $digressivePrice */ foreach ($loopResult->getResultDataCollection() as $digressivePrice) { $loopResultRow = new LoopResultRow($digressivePrice); // Get product $productId = $digressivePrice->getProductId(); $product = ProductQuery::create()->findOneById($productId); // Get prices $price = $digressivePrice->getPrice(); $promo = $digressivePrice->getPromoPrice(); // Get country $taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry(); // Get taxed prices $taxedPrice = $product->getTaxedPrice($taxCountry, $price); $taxedPromoPrice = $product->getTaxedPromoPrice($taxCountry, $promo); $loopResultRow ->set("ID", $digressivePrice->getId()) ->set("PRODUCT_ID", $productId) ->set("QUANTITY_FROM", $digressivePrice->getQuantityFrom()) ->set("QUANTITY_TO", $digressivePrice->getQuantityTo()) ->set("PRICE", $price) ->set("PROMO_PRICE", $promo) ->set("TAXED_PRICE", $taxedPrice) ->set("TAXED_PROMO_PRICE", $taxedPromoPrice); $loopResult->addRow($loopResultRow); } return $loopResult; } }