Pregunta

I want to apply my catalog promotion price rule for products having tier price as well. Current magento functionality only checks the price minimum value and displays the least among the both but I need the percentage rule amount discounted on tier price too.

¿Fue útil?

Solución

Native magento doesn't support applying catalog promotion rule on tier prices and special prices but we can achieve this by extending some of the core files in magento. You can find the _applyTierPrice() method in path

\vendor\magento\module-catalog\Model\Product\Type\Price.php


protected function _applyTierPrice($product, $qty, $finalPrice)
    {
        if ($qty === null) {
            return $finalPrice;
        }
        $tierPrice = $product->getTierPrice($qty);
        if (is_numeric($tierPrice)) {
            $finalPrice = min($finalPrice, $tierPrice);
        }
        return $finalPrice;
    }

and in this file down you can get the promotional rule applied price in method calculatePrice() around line no 578 like and check for the min value.

$rulePrice = $this->_ruleFactory->create()->getRulePrice($date, $wId, $gId, $productId);

The rule factory is in constructor like \Magento\CatalogRule\Model\ResourceModel\RuleFactory $ruleFactory,`

you can also refer the calcProductPriceRule() in the vendor\magento\module-catalog-rule\Model\Rule.php to get the promo price of product and then comparing the values you can return your desired value to final price.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top