Need a help in this issue. I am trying to remove a MySQL condition from _initSelect from this Collection "Magento\SalesRule\Model\ResourceModel\Rule\Collection". This Collection has the following _initSelect.
public function _initSelect()
{
parent::_initSelect();
$this->getSelect()->joinLeft(
['rule_coupons' => $this->getTable('salesrule_coupon')],
'main_table.rule_id = rule_coupons.rule_id AND rule_coupons.is_primary = 1',
['code']
);
return $this;
}
I am trying to modify the sql conditions using after_initSelect in a Plugin as follows.
namespace myModule\Promotion\Model\Plugin\Rule;
class RuleCollection
{
public function after_initSelect(\Magento\SalesRule\Model\ResourceModel\Rule\Collection $subject, $result) {
\Magento\Rule\Model\ResourceModel\Rule\Collection\AbstractCollection::_initSelect();
$this->getSelect()->joinLeft(
['rule_coupons' => $this->getTable('salesrule_coupon')],
'main_table.rule_id = rule_coupons.rule_id AND rule_coupons.is_primary = 0',
['code']
);
return $this;
}
}
My Plugin is getting recognized but this line "\Magento\Rule\Model\ResourceModel\Rule\Collection\AbstractCollection::_initSelect();" is throwing me errors saying "Error: Call to protected method Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::_initSelect()".
Can anyone help with what am I missing. TIA.