I need to create an indexer for cart price rules.
I decided to iterate the values from sales_rules table and extract the products from conditions_serialized coloumn.
My indexer file is like below.i Will share the executeFull
method only here
public function executeFull(){
$this->connection->truncateTable(
$this->getTable('salaesrule_product_reminder_index')
);
$salesRules = $this->ruleFactory->create()->getCollection()->addFieldToFilter('is_active', '1');;
foreach ($salesRules as $salesRule) {
$ruleId = $salesRule->getRuleId();
$conditions = $salesRule->getConditionsSerialized();
// Here i want to perform the insert task based on the product extract from above
}
}
I am stuck here on extracting the $conditions return json and getting the product_id based on SKU.
Sample return json is something like below.
{
"type":"Magento\SalesRule\Model\Rule\Condition\Combine",
"attribute":null,
"operator":null,
"value":"1",
"is_value_processed":null,
"aggregator":"all",
"conditions":[
{
"type":"Magento\SalesRule\Model\Rule\Condition\Product\Found",
"attribute":null,"operator":null,
"value":"1",
"is_value_processed":null,
"aggregator":"all",
"conditions":[
{
"type":"Magento\SalesRule\Model\Rule\Condition\Product",
"attribute":"sku",
"operator":"==",
"value":"16-02-07938, 16-02-07939, 16-02-08413",
"is_value_processed":false,
"attribute_scope":""
}
]
}
]
}
How magento do this kind of extraction on checking the cart rules against a product in cart? This kind of validation happen with produt Id or SKU?
Can anyone give me some insights on this question to proceed further?