Ejemplo n.º 1
0
 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
 {
     $data = array();
     $data['store_id'] = $attribute->getStoreId();
     $data['entity_id'] = $object->getId();
     $data['attribute_id'] = $attribute->getId();
     $result = array();
     $values = $object->getData($attribute->getAttributeCode());
     if (!is_array($values)) {
         return $result;
     }
     foreach ($values as $row) {
         if (isset($row['delete']) && $row['delete']) {
             continue;
         }
         $data['qty'] = $row['price_qty'];
         $data['value'] = $row['price'];
         if ($row['cust_group'] == Mage_Customer_Model_Group::CUST_GROUP_ALL) {
             foreach ($this->_customerGroups as $group) {
                 $data['customer_group_id'] = $group->getId();
                 $result[] = $data;
             }
         } else {
             $data['customer_group_id'] = $row['cust_group'];
             $result[] = $data;
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 public function callbackFilterMotorsAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if (is_null($value)) {
         return;
     }
     if (!$this->motorsAttribute) {
         return;
     }
     if ($value == 1) {
         $attributeCode = $this->motorsAttribute->getAttributeCode();
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => ''));
         $collection->addFieldToFilter('is_motors_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $attributeId = $this->motorsAttribute->getId();
         $storeId = $this->getListing()->getStoreId();
         $joinCondition = 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId;
         if (!$this->motorsAttribute->isScopeGlobal()) {
             $joinCondition .= ' and eaa.store_id = ' . $storeId;
         }
         $collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), $joinCondition, array('value'));
         $collection->getSelect()->orWhere('eaa.value IS NULL');
         $collection->getSelect()->orWhere('eaa.value = \'\'');
         $collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL');
     }
 }
 /**
  * Retrieve Select for update Flat data
  *
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   int $store
  * @param   bool $hasValueField flag which require option value
  * @return  Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
 {
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $valueExpr = new Zend_Db_Expr("IFNULL(t2.value, t1.value)");
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), "`e`.`entity_id`=`t1`.`entity_id` AND `e`.`child_id`=`t1`.`entity_id`", array())->joinLeft(array('t2' => $attributeTable), "`t2`.`entity_id`=`t1`.`entity_id`" . " AND `t1`.`entity_type_id`=`t2`.`entity_type_id`" . " AND `t1`.`attribute_id`=`t2`.`attribute_id`" . " AND `t2`.`store_id`={$store}", array($attributeCode => $valueExpr));
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)"));
     }
     $select->where('t1.entity_type_id=?', $attribute->getEntityTypeId())->where('t1.attribute_id=?', $attribute->getId())->where('t1.store_id=?', 0);
     return $select;
 }
 /**
  * @param Mage_Eav_Model_Entity_Type $object
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $value
  * @return $this
  * @throws Mage_Core_Exception
  */
 protected function _saveAttribute($object, $attribute, $value)
 {
     $table = $attribute->getBackend()->getTable();
     if (!isset($this->_attributeValuesToSave[$table])) {
         $this->_attributeValuesToSave[$table] = array();
     }
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $data = array('entity_type_id' => $object->getEntityTypeId(), $entityIdField => $object->getId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute));
     $this->_attributeValuesToSave[$table][] = $data;
     $this->_saveEntityData($object);
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Delete product data
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return Mage_Weee_Model_Resource_Attribute_Backend_Weee_Tax
  */
 public function deleteProductData($product, $attribute)
 {
     $where = array('entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId());
     $adapter = $this->_getWriteAdapter();
     if (!$attribute->isScopeGlobal()) {
         $storeId = $product->getStoreId();
         if ($storeId) {
             $where['website_id IN(?)'] = array(0, Mage::app()->getStore($storeId)->getWebsiteId());
         }
     }
     $adapter->delete($this->getMainTable(), $where);
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Retrieve Select for update Flat data
  *
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   int $store
  * @param   bool $hasValueField flag which require option value
  * @return  Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
 {
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $joinConditionTemplate = "`e`.`entity_id`=`%s`.`entity_id`" . " AND `%s`.`entity_type_id` = " . $attribute->getEntityTypeId() . " AND `%s`.`attribute_id` = " . $attribute->getId() . " AND `%s`.`store_id` = %d";
     $joinCondition = sprintf($joinConditionTemplate, 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
     }
     $valueExpr = new Zend_Db_Expr("IF(t2.value_id>0, t2.value, t1.value)");
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr));
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)"));
     }
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child=?", 0);
     }
     return $select;
 }
Ejemplo n.º 7
0
 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
 {
     $data = array();
     $data['store_id'] = $attribute->getStoreId();
     $data['entity_id'] = $object->getId();
     $data['attribute_id'] = $attribute->getId();
     $data['value'] = $object->getData($attribute->getAttributeCode());
     if ($attribute->getFrontendInput() == 'multiselect') {
         $origData = $data;
         $data = array();
         $value = explode(',', $origData['value']);
         foreach ($value as $item) {
             $row = $origData;
             $row['value'] = $item;
             $data[] = $row;
         }
     }
     //return $this->_spreadDataForStores($object, $attribute, $data);
     return $data;
 }
Ejemplo n.º 8
0
 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
 {
     $data = array();
     $data['store_id'] = $attribute->getStoreId();
     $data['entity_id'] = $object->getId();
     $data['attribute_id'] = $attribute->getId();
     $data['value'] = $object->getData($attribute->getAttributeCode());
     if ($attribute->getAttributeCode() == 'price') {
         $result = array();
         foreach ($this->_customerGroups as $group) {
             $object->setCustomerGroupId($group->getId());
             $finalPrice = $object->getFinalPrice();
             $row = $data;
             $row['customer_group_id'] = $group->getId();
             $row['value'] = $finalPrice;
             $result[] = $row;
         }
         return $result;
     }
     return $data;
 }
 /**
  * Retrieve Select for update Flat data
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @param bool $hasValueField flag which require option value
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
 {
     $adapter = $this->_getReadAdapter();
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $joinConditionTemplate = "%s.entity_id = %s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
     $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= ' AND e.child_id = t1.entity_id';
     }
     $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
     /** @var $select Varien_Db_Select */
     $select = $adapter->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 'e', 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr));
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $valueIdExpr = $adapter->getCheckSql('to2.value_id > 0', 'to2.value', 'to1.value');
         $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "to1.option_id = {$valueExpr} AND to1.store_id = 0", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), $adapter->quoteInto("to2.option_id = {$valueExpr} AND to2.store_id = ?", $store), array($attributeCode . '_value' => $valueIdExpr));
     }
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child = ?", 0);
     }
     return $select;
 }
Ejemplo n.º 10
0
 public function callbackFilterPartsCompatibilityAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if ($value == null) {
         return;
     }
     if (!$this->partsCompatibilityAttribute) {
         return;
     }
     if ($value == 1) {
         $attributeCode = $this->partsCompatibilityAttribute->getAttributeCode();
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => '\'\''));
         $collection->addFieldToFilter('is_parts_compatibility_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $attributeId = $this->partsCompatibilityAttribute->getId();
         $storeId = $this->getListing()->getStoreId();
         $collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId . ' and eaa.store_id = ' . $storeId);
         $collection->getSelect()->orWhere('eaa.value IS NULL');
         $collection->getSelect()->orWhere('eaa.value = \'\'');
         $collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL');
     }
 }
Ejemplo n.º 11
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $storeId
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $storeId)
 {
     $adapter = $this->_getReadAdapter();
     $joinConditionTemplate = "%s.entity_id=%s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
     $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= ' AND e.child_id = t1.entity_id';
     }
     $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
     /** @var $select Varien_Db_Select */
     $select = $adapter->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $storeId), array($attribute->getAttributeCode() => $valueExpr));
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child = ?", 0);
     }
     return $select;
 }
Ejemplo n.º 12
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
 {
     $joinCondition = "`e`.`entity_id`=`t1`.`entity_id`";
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
     }
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), "t2.entity_id = t1.entity_id" . " AND t1.entity_type_id = t2.entity_type_id" . " AND t1.attribute_id = t2.attribute_id" . " AND t2.store_id = {$store}", array($attribute->getAttributeCode() => "IF(t2.value_id>0, t2.value, t1.value)"))->where("t1.entity_type_id=?", $attribute->getEntityTypeId())->where("t1.attribute_id=?", $attribute->getId())->where("t1.store_id=?", 0);
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child=?", 0);
     }
     return $select;
 }
Ejemplo n.º 13
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
 {
     return $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), "`e`.`entity_id`=`t1`.`entity_id` AND `e`.`child_id`=`t1`.`entity_id`", array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), "t2.entity_id = t1.entity_id" . " AND t1.entity_type_id = t2.entity_type_id" . " AND t1.attribute_id = t2.attribute_id" . " AND t2.store_id = {$store}", array($attribute->getAttributeCode() => "IFNULL(t2.value, t1.value)"))->where("t1.entity_type_id=?", $attribute->getEntityTypeId())->where("t1.attribute_id=?", $attribute->getId())->where("t1.store_id=?", 0)->where("e.is_child=?", 0);
 }
Ejemplo n.º 14
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
 {
     $joinConditionTemplate = "`e`.`entity_id`=`%s`.`entity_id`" . " AND `%s`.`entity_type_id` = " . $attribute->getEntityTypeId() . " AND `%s`.`attribute_id` = " . $attribute->getId() . " AND `%s`.`store_id` = %d";
     $joinCondition = sprintf($joinConditionTemplate, 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
     }
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), sprintf($joinConditionTemplate, 't2', 't2', 't2', 't2', $store), array($attribute->getAttributeCode() => "IF(t2.value_id>0, t2.value, t1.value)"));
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child=?", 0);
     }
     return $select;
 }
Ejemplo n.º 15
0
 /**
  * Insert entity attribute value
  *
  * @param   Varien_Object $object
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   mixed $value
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _insertAttribute($object, $attribute, $value)
 {
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $row = array($entityIdField => $object->getId(), 'entity_type_id' => $object->getEntityTypeId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute));
     $this->_getWriteAdapter()->insert($attribute->getBackend()->getTable(), $row);
     return $this;
 }
 /**
  * Update entity attribute value
  *
  * @param   Varien_Object $object
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   mixed $valueId
  * @param   mixed $value
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _updateAttribute($object, $attribute, $valueId, $value)
 {
     /**
      * If we work in single store mode all values should be saved just
      * for default store id
      * In this case we clear all not default values
      */
     if (AO::app()->isSingleStoreMode()) {
         $this->_getWriteAdapter()->delete($attribute->getBackend()->getTable(), $this->_getWriteAdapter()->quoteInto('attribute_id=?', $attribute->getId()) . $this->_getWriteAdapter()->quoteInto(' AND entity_id=?', $object->getId()) . $this->_getWriteAdapter()->quoteInto(' AND store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID));
     }
     /**
      * Update attribute value for store
      */
     if ($attribute->isScopeStore()) {
         $this->_updateAttributeForStore($object, $attribute, $value, $object->getStoreId());
     } elseif ($attribute->isScopeWebsite()) {
         if ($object->getStoreId() == 0) {
             $this->_updateAttributeForStore($object, $attribute, $value, $object->getStoreId());
         } else {
             if (is_array($object->getWebsiteStoreIds())) {
                 foreach ($object->getWebsiteStoreIds() as $storeId) {
                     $this->_updateAttributeForStore($object, $attribute, $value, $storeId);
                 }
             }
         }
     } else {
         $this->_getWriteAdapter()->update($attribute->getBackend()->getTable(), array('value' => $this->_prepareValueForSave($value, $attribute)), 'value_id=' . (int) $valueId);
     }
     return $this;
 }
Ejemplo n.º 17
0
 /**
  * Save Options prices (Depends from price save scope)
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Type_Configurable_Attribute
  */
 public function savePrices($attribute)
 {
     $newValues = $attribute->getValues();
     $oldValues = array();
     $valueIndexes = array();
     $select = $this->_getWriteAdapter()->select()->from($this->_priceTable)->where('product_super_attribute_id=?', $attribute->getId());
     $query = $this->_getWriteAdapter()->query($select);
     while ($row = $query->fetch()) {
         $key = join('-', array($row['website_id'], $row['value_index']));
         $oldValues[$key] = $row;
     }
     $delete = array();
     $insert = array();
     $update = array();
     foreach ($newValues as $value) {
         $valueIndexes[$value['value_index']] = $value['value_index'];
     }
     if ($this->getCatalogHelper()->isPriceGlobal()) {
         foreach ($oldValues as $row) {
             if (!isset($valueIndexes[$row['value_index']])) {
                 $delete[] = $row['value_id'];
                 continue;
             }
         }
         foreach ($newValues as $value) {
             $valueObject = new Varien_Object($value);
             $key = join('-', array(0, $value['value_index']));
             $pricingValue = $valueObject->getPricingValue();
             if ($pricingValue == '' || is_null($pricingValue)) {
                 $pricingValue = null;
             } else {
                 $pricingValue = Mage::app()->getLocale()->getNumber($pricingValue);
             }
             // update
             if (isset($oldValues[$key])) {
                 $oldValue = $oldValues[$key];
                 $update[$oldValue['value_id']] = array('pricing_value' => $pricingValue, 'is_percent' => intval($valueObject->getIsPercent()));
             } else {
                 if (!empty($value['pricing_value'])) {
                     $insert[] = array('product_super_attribute_id' => $attribute->getId(), 'value_index' => $valueObject->getValueIndex(), 'is_percent' => intval($valueObject->getIsPercent()), 'pricing_value' => $pricingValue, 'website_id' => 0);
                 }
             }
         }
     } else {
         $websiteId = Mage::app()->getStore($attribute->getStoreId())->getWebsiteId();
         foreach ($oldValues as $row) {
             if (!isset($valueIndexes[$row['value_index']])) {
                 $delete[] = $row['value_id'];
                 continue;
             }
         }
         foreach ($newValues as $value) {
             $valueObject = new Varien_Object($value);
             $key = join('-', array($websiteId, $value['value_index']));
             $pricingValue = $valueObject->getPricingValue();
             if ($pricingValue == '' || is_null($pricingValue)) {
                 $pricingValue = null;
             } else {
                 $pricingValue = Mage::app()->getLocale()->getNumber($pricingValue);
             }
             // update
             if (isset($oldValues[$key])) {
                 $oldValue = $oldValues[$key];
                 if ($websiteId && $valueObject->getUseDefaultValue()) {
                     $delete[] = $oldValue['value_id'];
                 } else {
                     $update[$oldValue['value_id']] = array('pricing_value' => $pricingValue, 'is_percent' => intval($valueObject->getIsPercent()));
                 }
             } else {
                 if ($websiteId && $valueObject->getUseDefaultValue()) {
                     continue;
                 }
                 $insert[] = array('product_super_attribute_id' => $attribute->getId(), 'value_index' => $valueObject->getValueIndex(), 'is_percent' => intval($valueObject->getIsPercent()), 'pricing_value' => $pricingValue, 'website_id' => $websiteId);
             }
             $key = join('-', array(0, $value['value_index']));
             if (!isset($oldValues[$key])) {
                 $insert[] = array('product_super_attribute_id' => $attribute->getId(), 'value_index' => $valueObject->getValueIndex(), 'is_percent' => 0, 'pricing_value' => null, 'website_id' => 0);
             }
         }
     }
     if (!empty($delete)) {
         $where = $this->_getWriteAdapter()->quoteInto('value_id IN(?)', $delete);
         $this->_getWriteAdapter()->delete($this->_priceTable, $where);
     }
     if (!empty($update)) {
         foreach ($update as $valueId => $valueData) {
             $where = $this->_getWriteAdapter()->quoteInto('value_id=?', $valueId);
             $this->_getWriteAdapter()->update($this->_priceTable, $valueData, $where);
         }
     }
     if (!empty($insert)) {
         foreach ($insert as $valueData) {
             $this->_getWriteAdapter()->insert($this->_priceTable, $valueData);
         }
     }
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Insert entity attribute value
  *
  * Insert attribute value we do only for default store
  *
  * @param   Varien_Object $object
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   mixed $value
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _insertAttribute($object, $attribute, $value)
 {
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $row = array($entityIdField => $object->getId(), 'entity_type_id' => $object->getEntityTypeId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute), 'store_id' => $this->getDefaultStoreId());
     $this->_getWriteAdapter()->insert($attribute->getBackend()->getTable(), $row);
     if ($object->getStoreId() != $this->getDefaultStoreId()) {
         $this->_updateAttribute($object, $attribute, $this->_getWriteAdapter()->lastInsertId(), $value);
     }
     return $this;
 }