Example #1
0
 /**
  * Return collection of same attributes for selected products without unique
  *
  * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection
  */
 public function getAttributes()
 {
     if (is_null($this->_attributes)) {
         $this->_attributes = Mage::getSingleton('Mage_Eav_Model_Config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection()->addIsNotUniqueFilter()->setInAllAttributeSetsFilter($this->getProductsSetIds());
         if ($this->_excludedAttributes) {
             $this->_attributes->addFieldToFilter('attribute_code', array('nin' => $this->_excludedAttributes));
         }
         // check product type apply to limitation and remove attributes that impossible to change in mass-update
         $productTypeIds = $this->getProducts()->getProductTypeIds();
         foreach ($this->_attributes as $attribute) {
             /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
             foreach ($productTypeIds as $productTypeId) {
                 $applyTo = $attribute->getApplyTo();
                 if (count($applyTo) > 0 && !in_array($productTypeId, $applyTo)) {
                     $this->_attributes->removeItemByKey($attribute->getId());
                     break;
                 }
             }
         }
     }
     return $this->_attributes;
 }
Example #2
0
 /**
  * Clean up 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)
 {
     $collection->load();
     foreach ($collection as $attribute) {
         if (in_array($attribute->getAttributeCode(), $this->_disabledAttrs)) {
             $collection->removeItemByKey($attribute->getId());
         }
     }
     return $collection;
 }