/** * 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; }
/** * Initialize collection select * * @return $this */ protected function _initSelect() { parent::_initSelect(); /** * Make sure this collection can not be used to access attributes from * entities not managed by Entity Type Manager extension */ $this->getSelect()->joinInner(array('etm_entity_type' => $this->getTable('goodahead_etm/eav_entity_type')), 'main_table.entity_type_id = etm_entity_type.entity_type_id', array()); // $this->getSelect()->joinInner( // array('etm_attribute' => $this->getTable('goodahead_etm/eav_attribute')), // 'main_table.attribute_id = etm_attribute.attribute_id' // ); return $this; }
/** * Add filters to attribute collection * * @param Mage_Eav_Model_Mysql4_Entity_Attribute_Collection $collection * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection */ protected function _prepareAttributeCollection($collection) { $collection->addIsFilterableInSearchFilter(); return $collection; }
/** * Return array of fields to load attribute values * * @return array */ protected function _getLoadDataFields() { $fields = array_merge(parent::_getLoadDataFields(), array('additional_table.is_global', 'additional_table.is_html_allowed_on_front', 'additional_table.is_wysiwyg_enabled')); return $fields; }
/** * Return array of fields to load attribute values * * @return array */ protected function _getLoadDataFields() { $fields = parent::_getLoadDataFields(); $fields = array_merge($fields, array('additional_table.is_global')); return $fields; }
/** * Clean up attribute collection. * * @param Mage_Eav_Model_Mysql4_Entity_Attribute_Collection $collection * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection */ public function filterAttributeCollection(Mage_Eav_Model_Mysql4_Entity_Attribute_Collection $collection) { $collection->load(); foreach ($collection as $attribute) { if (in_array($attribute->getAttributeCode(), $this->_disabledAttrs)) { $collection->removeItemByKey($attribute->getId()); } } return $collection; }