I am trying to set conditions programatically using the following code:
$conditionObj = array( 'type'=>'salesrule/rule_condition_combine', 'attribute'=>'', 'operator'=>'', 'value'=>'1', 'is_value_processed'=>'', 'aggregator'=>'', 'conditions'=>array(array( 'type'=>'salesrule/rule_condition_product_found', 'attribute'=>'', 'operator'=>'', 'value'=>'1', 'is_value_processed'=>'', 'aggregator'=>'any', 'conditions'=>array(array( 'type'=>'salesrule/rule_condition_product', 'attribute'=>'sku', 'operator'=>'()', 'value'=>'Organika-1149', 'is_value_processed'=>'', )/*,array( 'type'=>'salesrule/rule_condition_product', 'attribute'=>'category_ids', 'operator'=>'()', 'value'=>implode(',',$newUserCategoryIds), 'is_value_processed'=>'', )*/) ) ) ); $conditionsSerialized = serialize($conditionObj); $ruleData['conditions_serialized'] = $conditionsSerialized;
However, I get this error when I try to do so:
{ "RC": 23000, "messages": { "error": [ { "code": 23000, "message": "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`goopter_api`.`salesrule_product_attribute`, CONSTRAINT `FK_SALESRULE_PRODUCT_ATTRIBUTE_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`) ON DELETE CASCADE ), query was: INSERT INTO `salesrule_product_attribute` () VALUES ()" }, { "code": 23000, "message": "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`goopter_api`.`salesrule_product_attribute`, CONSTRAINT `FK_SALESRULE_PRODUCT_ATTRIBUTE_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`) ON DELETE CASCADE ), query was: INSERT INTO `salesrule_product_attribute` () VALUES ()" } ] } }
I have looked into the sales_product_attribute table and it does not have a 'sku' table only 'attribute_id'. How am I supposed to set conditions for sku and category id then without getting this error?
Solved! Go to Solution.
Solved after looking through all log outputs(tail -f *log) and debugging warnings. Mine worked after I set website id data type to array instead of int.
Interactive content can be a great way to generate leads for your business. Quizzes and polls, for example, can be used to collect contact information from website visitors.