I’ve been tasked with fixing the price filter on a Magento 2 site.
It works fine with normal products, but a new “grouped_product_price” has been added to Grouped Products as part of a custom module.
I want to apply a condition to the current query which basically says:
If there’s a grouped_product_price attribute value then check that value, otherwise use the normal price
For dev purposes I’m working in vendor/magento/module-catalog-search/Model/Layer/Filter/
Price.php
Once it’s working I’ll be moving this to a module.
This query returns some values:
$this->getLayer()->getProductCollection()->addFieldToFilter(
'price',
['from' => $from, 'to' => empty($to) || $from == $to ? $to : $to - self::PRICE_DELTA]
)->addAttributeToFilter('grouped_product_price',['gt'=> empty($to) || $from == $to ? $to : $to - self::PRICE_DELTA]);
But it’s an AND query, which isn’t what I want.
I know I’m close to sorting this.
Any ideas?