/**
  * Delete entity attribute values
  *
  * @param Varien_Object $object
  * @param string $table
  * @param array $info
  * @return Mage_Catalog_Model_Resource_Abstract
  */
 protected function _deleteAttributes($object, $table, $info)
 {
     $adapter = $this->_getWriteAdapter();
     $entityIdField = $this->getEntityIdField();
     $globalValues = array();
     $websiteAttributes = array();
     $storeAttributes = array();
     /**
      * Separate attributes by scope
      */
     foreach ($info as $itemData) {
         $attribute = $this->getAttribute($itemData['attribute_id']);
         if ($attribute->isScopeStore()) {
             $storeAttributes[] = (int) $itemData['attribute_id'];
         } elseif ($attribute->isScopeWebsite()) {
             $websiteAttributes[] = (int) $itemData['attribute_id'];
         } else {
             $globalValues[] = (int) $itemData['value_id'];
         }
     }
     /**
      * Delete global scope attributes
      */
     if (!empty($globalValues)) {
         $adapter->delete($table, array('value_id IN (?)' => $globalValues));
     }
     $condition = array($entityIdField . ' = ?' => $object->getId(), 'entity_type_id = ?' => $object->getEntityTypeId());
     /**
      * Delete website scope attributes
      */
     if (!empty($websiteAttributes)) {
         $storeIds = $object->getWebsiteStoreIds();
         if (!empty($storeIds)) {
             $delCondition = $condition;
             $delCondition['attribute_id IN(?)'] = $websiteAttributes;
             $delCondition['store_id IN(?)'] = $storeIds;
             $adapter->delete($table, $delCondition);
         }
     }
     /**
      * Delete store scope attributes
      */
     if (!empty($storeAttributes)) {
         $delCondition = $condition;
         $delCondition['attribute_id IN(?)'] = $storeAttributes;
         $delCondition['store_id = ?'] = (int) $object->getStoreId();
         $adapter->delete($table, $delCondition);
     }
     return $this;
 }
Example #2
0
 /**
  * Delete entity attribute values
  *
  * @param   Varien_Object $object
  * @param   string $table
  * @param   array $info
  * @return  Varien_Object
  */
 protected function _deleteAttributes($object, $table, $info)
 {
     $entityIdField = $this->getEntityIdField();
     $globalValues = array();
     $websiteAttributes = array();
     $storeAttributes = array();
     /**
      * Separate attributes by scope
      */
     foreach ($info as $itemData) {
         $attribute = $this->getAttribute($itemData['attribute_id']);
         if ($attribute->isScopeStore()) {
             $storeAttributes[] = $itemData['attribute_id'];
         } elseif ($attribute->isScopeWebsite()) {
             $websiteAttributes[] = $itemData['attribute_id'];
         } else {
             $globalValues[] = $itemData['value_id'];
         }
     }
     /**
      * Delete global scope attributes
      */
     if (!empty($globalValues)) {
         $condition = $this->_getWriteAdapter()->quoteInto('value_id IN (?)', $globalValues);
         $this->_getWriteAdapter()->delete($table, $condition);
     }
     $condition = $this->_getWriteAdapter()->quoteInto("{$entityIdField}=?", $object->getId()) . $this->_getWriteAdapter()->quoteInto(' AND entity_type_id=?', $object->getEntityTypeId());
     /**
      * Delete website scope attributes
      */
     if (!empty($websiteAttributes)) {
         $storeIds = $object->getWebsiteStoreIds();
         if (!empty($storeIds)) {
             $delCondition = $condition . $this->_getWriteAdapter()->quoteInto(' AND attribute_id IN(?)', $websiteAttributes) . $this->_getWriteAdapter()->quoteInto(' AND store_id IN(?)', $storeIds);
             $this->_getWriteAdapter()->delete($table, $delCondition);
         }
     }
     /**
      * Delete store scope attributes
      */
     if (!empty($storeAttributes)) {
         $delCondition = $condition . $this->_getWriteAdapter()->quoteInto(' AND attribute_id IN(?)', $storeAttributes) . $this->_getWriteAdapter()->quoteInto(' AND store_id =?', $object->getStoreId());
         $this->_getWriteAdapter()->delete($table, $delCondition);
     }
     return $this;
 }