public function setCollection($collection) { if ($this->_allowUpdateCollection && !Mage::getSingleton('aitpermissions/role')->isPermissionsEnabled() && Mage::helper('aitpermissions')->isShowProductOwner()) { $collection->joinAttribute('created_by', 'catalog_product/created_by', 'entity_id', null, 'left'); } return parent::setCollection($collection); }
/** * set collection object * * @param Varien_Data_Collection $collection */ public function setCollection($collection) { if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) { $select = $collection->getSelect(); $fromParts = $select->getPart(Zend_Db_Select::FROM); if (isset($fromParts['at_qty'])) { unset($fromParts['at_qty']); $select->reset(Zend_Db_Select::FROM); $select->setPart(Zend_Db_Select::FROM, $fromParts); $subquery = $collection->getConnection()->select()->from(array('at_sub_qty' => $collection->getResource()->getTable('cataloginventory/stock_item')), array('product_id'))->columns(new Zend_Db_Expr("SUM(at_sub_qty.qty) AS qty"))->group('at_sub_qty.product_id'); $select->joinLeft(array('at_qty' => $subquery), 'at_qty.product_id=e.entity_id', array()); } } parent::setCollection($collection); }
public function setCollection($collection) { $store = $this->_getStore(); $this->_prepareCollectionExtra($collection, $store); if (!Mage::registry('product_collection')) { Mage::register('product_collection', $collection); } /** * Adding attributes */ if ($this->_gridAttributes->getSize() > 0) { foreach ($this->_gridAttributes as $attribute) { $collection->joinAttribute($attribute->getAttributeCode(), 'catalog_product/' . $attribute->getAttributeCode(), 'entity_id', null, 'left', $store->getId()); } } return parent::setCollection($collection); }