/** * Retrive same attributes for selected products without unique * * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection */ public function getAttributes() { if (is_null($this->_attributes)) { $this->_attributes = $this->getProducts()->getEntity()->getEntityType()->getAttributeCollection()->addIsNotUniqueFilter()->setInAllAttributeSetsFilter($this->getProductsSetIds()); foreach ($this->_excludedAttributes as $attributeCode) { $this->_attributes->addFieldToFilter('attribute_code', array('neq' => $attributeCode)); } $this->_attributes->load(); foreach ($this->_attributes as $attribute) { $attribute->setEntity($this->getProducts()->getEntity()); } } return $this->_attributes; }
/** * Return collection of same attributes for selected products without unique * * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection */ public function getAttributes() { if (is_null($this->_attributes)) { $this->_attributes = Mage::getSingleton('eav/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; }