/** * Prepare and Save Matched products for Rule * * @deprecated after 1.11.2.0 * * @param Enterprise_TargetRule_Model_Rule $object * * @return Enterprise_TargetRule_Model_Resource_Rule */ protected function _prepareRuleProducts($object) { $this->unbindRuleFromEntity($object->getId(), array(), 'product'); $this->bindRuleToEntity($object->getId(), $object->getMatchingProductIds(), 'product'); return $this; }
/** * Prepare and Save Matched products for Rule * * @param Enterprise_TargetRule_Model_Rule $object * @return Enterprise_TargetRule_Model_Mysql4_Rule */ protected function _prepareRuleProducts($object) { $adapter = $this->_getWriteAdapter(); // remove old matched products $ruleId = $object->getId(); $adapter->delete($this->_getRuleProductsTable(), array('rule_id=?' => $ruleId)); // retrieve and save new matched product ids $chunk = array_chunk($object->getMatchingProductIds(), 1000); foreach ($chunk as $productIds) { $data = array(); foreach ($productIds as $productId) { $data[] = array('rule_id' => $ruleId, 'product_id' => $productId, 'store_id' => 0); } if ($data) { $adapter->insertMultiple($this->_getRuleProductsTable(), $data); } } return $this; }