/** * Inner join the groupscatalog index table to hide entities not visible to the specified customer group id * * @param Varien_Data_Collection_Db $collection * @param int $groupId The customer group id * @return void */ public function addGroupsCatalogFilterToCollection(Varien_Data_Collection_Db $collection, $groupId) { /* @var $helper Netzarbeiter_GroupsCatalog2_Helper_Data */ $helper = Mage::helper('netzarbeiter_groupscatalog2'); /** * This is slightly complicated but it works with products and * categories whether the flat tables enabled or not * * @var $entityType string * @var $entity Mage_Catalog_Model_Abstract */ $entity = $collection->getNewEmptyItem(); $entityType = $helper->getEntityTypeCodeFromEntity($entity); $this->_init($helper->getIndexTableByEntityType($entityType), 'id'); if ($this->_doesIndexExists()) { $filterTable = $collection->getResource()->getTable($helper->getIndexTableByEntityType($entityType)); $entityIdField = "{$this->_getCollectionTableAlias($collection)}.entity_id"; $this->_addGroupsCatalogFilterToSelect($collection->getSelect(), $filterTable, $groupId, $collection->getStoreId(), $entityIdField); } }
/** * Retrieve collection empty item * * @return Varien_Object */ public function getNewEmptyItem() { /* @var $item Mzax_Emarketing_Model_Object_Collection_Item */ $item = parent::getNewEmptyItem(); $item->setObject($this->getObject()); return $item; }