/** * {@inheritdoc} */ public function getWebsiteIds() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getWebsiteIds'); if (!$pluginInfo) { return parent::getWebsiteIds(); } else { return $this->___callPlugins('getWebsiteIds', func_get_args(), $pluginInfo); } }
/** * Save product attributes currently used in conditions and actions of rule * * @param \Magento\SalesRule\Model\Rule $rule * @param mixed $attributes * @return $this */ public function setActualProductAttributes($rule, $attributes) { $connection = $this->getConnection(); $connection->delete($this->getTable('salesrule_product_attribute'), ['rule_id=?' => $rule->getId()]); //Getting attribute IDs for attribute codes $attributeIds = []; $select = $this->getConnection()->select()->from(['a' => $this->getTable('eav_attribute')], ['a.attribute_id'])->where('a.attribute_code IN (?)', [$attributes]); $attributesFound = $this->getConnection()->fetchAll($select); if ($attributesFound) { foreach ($attributesFound as $attribute) { $attributeIds[] = $attribute['attribute_id']; } $data = []; foreach ($rule->getCustomerGroupIds() as $customerGroupId) { foreach ($rule->getWebsiteIds() as $websiteId) { foreach ($attributeIds as $attribute) { $data[] = ['rule_id' => $rule->getId(), 'website_id' => $websiteId, 'customer_group_id' => $customerGroupId, 'attribute_id' => $attribute]; } } } $connection->insertMultiple($this->getTable('salesrule_product_attribute'), $data); } return $this; }
/** * Save product attributes currently used in conditions and actions of rule * * @param \Magento\SalesRule\Model\Rule $rule * @param mixed $attributes * @return $this */ public function setActualProductAttributes($rule, $attributes) { $write = $this->_getWriteAdapter(); $write->delete($this->getTable('salesrule_product_attribute'), array('rule_id=?' => $rule->getId())); //Getting attribute IDs for attribute codes $attributeIds = array(); $select = $this->_getReadAdapter()->select()->from(array('a' => $this->getTable('eav_attribute')), array('a.attribute_id'))->where('a.attribute_code IN (?)', array($attributes)); $attributesFound = $this->_getReadAdapter()->fetchAll($select); if ($attributesFound) { foreach ($attributesFound as $attribute) { $attributeIds[] = $attribute['attribute_id']; } $data = array(); foreach ($rule->getCustomerGroupIds() as $customerGroupId) { foreach ($rule->getWebsiteIds() as $websiteId) { foreach ($attributeIds as $attribute) { $data[] = array('rule_id' => $rule->getId(), 'website_id' => $websiteId, 'customer_group_id' => $customerGroupId, 'attribute_id' => $attribute); } } } $write->insertMultiple($this->getTable('salesrule_product_attribute'), $data); } return $this; }