Ejemplo n.º 1
0
 protected function _checkEntityEditableAttribute($type, $config, $params, $entity)
 {
     if (parent::_checkEntityEditableAttribute($type, $config, $params, $entity)) {
         $productAttributes = $entity->getAttributes();
         $searchedCode = $config['config']['attribute']->getAttributeCode();
         $isEditable = false;
         foreach ($productAttributes as $attribute) {
             if ($attribute->getAttributeCode() == $searchedCode) {
                 $isEditable = true;
                 break;
             }
         }
         if ($entity->hasLockedAttributes()) {
             if (in_array($searchedCode, $entity->getLockedAttributes())) {
                 Mage::throwException(Mage::helper('customgrid')->__('This attribute is locked'));
             }
         }
         if ($entity->getStoreId() != 0 && !in_array($entity->getStoreId(), $entity->getStoreIds())) {
             Mage::throwException(Mage::helper('customgrid')->__('The product is not associated to the corresponding website'));
         }
         if ($isEditable) {
             if ($entity->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
                 // @todo all MAP stuff from 1.6, and handle attributes with "Use config" (such as gift_message_available too)
                 if (in_array($searchedCode, array('price', 'sku', 'special_price', 'tier_price', 'weight'))) {
                     Mage::throwException(Mage::helper('customgrid')->__('This attribute is not editable for bundle products'));
                 }
             }
             return true;
         } else {
             Mage::throwException(Mage::helper('customgrid')->__('This attribute is not editable for this product'));
         }
     }
     return false;
 }