Exemple #1
0
 /**
  * Clean up already loaded attribute collection.
  *
  * @param Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection
  * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection
  */
 public function filterAttributeCollection(Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection)
 {
     $validTypes = array_keys($this->_productTypeModels);
     foreach (parent::filterAttributeCollection($collection) as $attribute) {
         $attrApplyTo = $attribute->getApplyTo();
         $attrApplyTo = $attrApplyTo ? array_intersect($attrApplyTo, $validTypes) : $validTypes;
         if ($attrApplyTo) {
             foreach ($attrApplyTo as $productType) {
                 // override attributes by its product type model
                 if ($this->_productTypeModels[$productType]->overrideAttribute($attribute)) {
                     break;
                 }
             }
         } else {
             // remove attributes of not-supported product types
             $collection->removeItemByKey($attribute->getId());
         }
     }
     return $collection;
 }
Exemple #2
0
 /**
  * Clean up already loaded attribute collection.
  *
  * @param Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection
  * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection
  */
 public function filterAttributeCollection(Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection)
 {
     foreach (parent::filterAttributeCollection($collection) as $attribute) {
         if (!empty($this->_attributeOverrides[$attribute->getAttributeCode()])) {
             $data = $this->_attributeOverrides[$attribute->getAttributeCode()];
             if (isset($data['options_method']) && method_exists($this, $data['options_method'])) {
                 $data['filter_options'] = $this->{$data}['options_method']();
             }
             $attribute->addData($data);
         }
     }
     return $collection;
 }