1

By default, Magento will choose the price assigned to "ALL GROUPS" over the price assigned to a customer group if customer group's price is higher than ALL GROUPS price.

I want to override this logic and show the customer group's price even ALL GROUPS price is lower.

I just want to determine which class and method should I override for me to implement this. Any idea?

2

Did you checked vendor/magento/module-catalog/Pricing/Price/TierPrice.php class?


/**
 * @param array $priceList
 * @return array
 */
protected function filterTierPrices(array $priceList)
{
    $qtyCache = [];
    $allCustomersGroupId = $this->groupManagement->getAllCustomersGroup()->getId();
    foreach ($priceList as $priceKey => &$price) {
        if ($price['price'] >= $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue()) {
            unset($priceList[$priceKey]);
            continue;
        }

        if (isset($price['price_qty']) && $price['price_qty'] == 1) {
            unset($priceList[$priceKey]);
            continue;
        }
        /* filter price by customer group */
        if ($price['cust_group'] != $this->customerGroup &&
            $price['cust_group'] != $allCustomersGroupId) {
            unset($priceList[$priceKey]);
            continue;
        }
        /* select a lower price for each quantity */
        if (isset($qtyCache[$price['price_qty']])) {
            $priceQty = $qtyCache[$price['price_qty']];
            if ($this->isFirstPriceBetter($price['website_price'], $priceList[$priceQty]['website_price'])) {
                unset($priceList[$priceQty]);
                $qtyCache[$price['price_qty']] = $priceKey;
            } else {
                unset($priceList[$priceKey]);
            }
        } else {
            $qtyCache[$price['price_qty']] = $priceKey;
        }
    }
    return array_values($priceList);
}
  • Thank you Sohel, this is indeed the method responsible for the tier price. I'm trying to intercept it through plugin but for some reason the plugin is not working. <type name="Magento\Catalog\Pricing\Price\TierPrice"> <plugin name="tier-price-intercepter" type="Zeald\GroupPrice\Plugin\Pricing\TierPrice" sortOrder="1" /> </type> Any idea why? – Eric Libay Feb 14 at 8:24
  • This is a protected method, so plugin not working. You need to create plugin for getTierPriceList method. – Sohel Rana Feb 14 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.