Skip to content

Instantly share code, notes, and snippets.

Created October 5, 2012 19:58
Show Gist options
  • Save anonymous/3842009 to your computer and use it in GitHub Desktop.
Save anonymous/3842009 to your computer and use it in GitHub Desktop.
Every _prepareCollection Grid method in a Magento 1.7.0.2 CE instal
File: Adminhtml/Block/Api/Grid/Role.php
function _prepareCollection()
{
$collection = Mage::getModel("api/roles")->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Api/Role/Grid/User.php
function _prepareCollection()
{
$roleId = $this->getRequest()->getParam('rid');
Mage::register('RID', $roleId);
$collection = Mage::getModel('api/roles')->getUsersCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Api/User/Edit/Tab/Roles.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('api/role_collection');
$collection->setRolesFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Api/User/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('api/user_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Backup/Grid.php
function _prepareCollection()
{
$collection = Mage::getSingleton('backup/fs_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Cache/Grid.php
function _prepareCollection()
{
$collection = new Varien_Data_Collection();
foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
$collection->addItem($type);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Category/Tab/Product.php
function _prepareCollection()
{
if ($this->getCategory()->getId()) {
$this->setDefaultFilter(array('in_category'=>1));
}
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('price')
->addStoreFilter($this->getRequest()->getParam('store'))
->joinField('position',
'catalog/category_product',
'position',
'product_id=entity_id',
'category_id='.(int) $this->getRequest()->getParam('id', 0),
'left');
$this->setCollection($collection);
if ($this->getCategory()->getProductsReadonly()) {
$productIds = $this->_getSelectedProducts();
if (empty($productIds)) {
$productIds = 0;
}
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Attribute/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('catalog/product_attribute_collection')
->addVisibleFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Attribute/Set/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::registry('entityType'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php
function _prepareCollection()
{
$productId = $this->getRequest()->getParam('id');
$websiteId = 0;
if ($store = $this->getRequest()->getParam('store')) {
$websiteId = Mage::app()->getStore($store)->getWebsiteId();
}
if (Mage::helper('catalog')->isModuleEnabled('Mage_ProductAlert')) {
$collection = Mage::getModel('productalert/price')
->getCustomerCollection()
->join($productId, $websiteId);
$this->setCollection($collection);
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php
function _prepareCollection()
{
$productId = $this->getRequest()->getParam('id');
$websiteId = 0;
if ($store = $this->getRequest()->getParam('store')) {
$websiteId = Mage::app()->getStore($store)->getWebsiteId();
}
if (Mage::helper('catalog')->isModuleEnabled('Mage_ProductAlert')) {
$collection = Mage::getModel('productalert/stock')
->getCustomerCollection()
->join($productId, $websiteId);
$this->setCollection($collection);
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php
function _prepareCollection()
{
/* @var $collection Mage_Catalog_Model_Resource_Product_Link_Product_Collection */
$collection = Mage::getModel('catalog/product_link')->useCrossSellLinks()
->getProductCollection()
->setProduct($this->_getProduct())
->addAttributeToSelect('*');
if ($this->isReadonly()) {
$productIds = $this->_getSelectedProducts();
if (empty($productIds)) {
$productIds = array(0);
}
$collection->addFieldToFilter('entity_id', array('in' => $productIds));
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php
function _prepareCollection()
{
$collection = Mage::getModel('catalog/product_link')->useRelatedLinks()
->getProductCollection()
->setProduct($this->_getProduct())
->addAttributeToSelect('*');
if ($this->isReadonly()) {
$productIds = $this->_getSelectedProducts();
if (empty($productIds)) {
$productIds = array(0);
}
$collection->addFieldToFilter('entity_id', array('in' => $productIds));
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid.php
function _prepareCollection()
{
$allowProductTypes = array();
foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
$allowProductTypes[] = $type->getName();
}
$product = $this->_getProduct();
$collection = $product->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id')
->addAttributeToSelect('price')
->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
->addFieldToFilter('type_id', $allowProductTypes)
->addFilterByRequiredOptions()
->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
}
foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
$collection->addAttributeToSelect($attribute->getAttributeCode());
$collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
}
$this->setCollection($collection);
if ($this->isReadonly()) {
$collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
}
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php
function _prepareCollection()
{
$allowProductTypes = array();
$allowProductTypeNodes = Mage::getConfig()
->getNode('global/catalog/product/type/grouped/allow_product_types')->children();
foreach ($allowProductTypeNodes as $type) {
$allowProductTypes[] = $type->getName();
}
$collection = Mage::getModel('catalog/product_link')->useGroupedLinks()
->getProductCollection()
->setProduct($this->_getProduct())
->addAttributeToSelect('*')
->addFilterByRequiredOptions()
->addAttributeToFilter('type_id', $allowProductTypes);
if ($this->getIsReadonly() === true) {
$collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php
function _prepareCollection()
{
if (Mage::helper('catalog')->isModuleEnabled('Mage_Tag')) {
$collection = Mage::getModel('tag/tag')
->getCustomerCollection()
->addProductFilter($this->getProductId())
->addGroupByTag()
->addDescOrder();
$this->setCollection($collection);
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.php
function _prepareCollection()
{
$collection = Mage::getModel('tag/tag')
->getResourceCollection()
->addProductFilter($this->getProductId())
->addPopularity();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php
function _prepareCollection()
{
$collection = Mage::getModel('catalog/product_link')->useUpSellLinks()
->getProductCollection()
->setProduct($this->_getProduct())
->addAttributeToSelect('*');
if ($this->isReadonly()) {
$productIds = $this->_getSelectedProducts();
if (empty($productIds)) {
$productIds = array(0);
}
$collection->addFieldToFilter('entity_id', array('in'=>$productIds));
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Grid.php
function _prepareCollection()
{
$store = $this->_getStore();
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id');
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$collection->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
}
if ($store->getId()) {
//$collection->setStoreId($store->getId());
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
$collection->addStoreFilter($store);
$collection->joinAttribute(
'name',
'catalog_product/name',
'entity_id',
null,
'inner',
$adminStore
);
$collection->joinAttribute(
'custom_name',
'catalog_product/name',
'entity_id',
null,
'inner',
$store->getId()
);
$collection->joinAttribute(
'status',
'catalog_product/status',
'entity_id',
null,
'inner',
$store->getId()
);
$collection->joinAttribute(
'visibility',
'catalog_product/visibility',
'entity_id',
null,
'inner',
$store->getId()
);
$collection->joinAttribute(
'price',
'catalog_product/price',
'entity_id',
null,
'left',
$store->getId()
);
}
else {
$collection->addAttributeToSelect('price');
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
}
$this->setCollection($collection);
parent::_prepareCollection();
$this->getCollection()->addWebsiteNamesToResult();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Product/Widget/Chooser.php
function _prepareCollection()
{
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
$collection = Mage::getResourceModel('catalog/product_collection')
->setStoreId(0)
->addAttributeToSelect('name');
if ($categoryId = $this->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($categoryId);
if ($category->getId()) {
// $collection->addCategoryFilter($category);
$productIds = $category->getProductsPosition();
$productIds = array_keys($productIds);
if (empty($productIds)) {
$productIds = 0;
}
$collection->addFieldToFilter('entity_id', array('in' => $productIds));
}
}
if ($productTypeId = $this->getProductTypeId()) {
$collection->addAttributeToFilter('type_id', $productTypeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Catalog/Search/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('catalogsearch/query')
->getResourceCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Checkout/Agreement/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('checkout/agreement')
->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Cms/Block/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('cms/block')->getCollection();
/* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Cms/Block/Widget/Chooser.php
function _prepareCollection()
{
$collection = Mage::getModel('cms/block')->getCollection();
/* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Cms/Page/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('cms/page')->getCollection();
/* @var $collection Mage_Cms_Model_Mysql4_Page_Collection */
$collection->setFirstStoreFlag(true);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Cms/Page/Widget/Chooser.php
function _prepareCollection()
{
$collection = Mage::getModel('cms/page')->getCollection();
/* @var $collection Mage_Cms_Model_Mysql4_Page_Collection */
$collection->setFirstStoreFlag(true);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/Cart.php
function _prepareCollection()
{
$customer = Mage::registry('current_customer');
$storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
$quote = Mage::getModel('sales/quote')
->setSharedStoreIds($storeIds)
->loadByCustomer($customer);
if ($quote) {
$collection = $quote->getItemsCollection(false);
}
else {
$collection = new Varien_Data_Collection();
}
$collection->addFieldToFilter('parent_item_id', array('null' => true));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/Newsletter/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('newsletter/queue_collection')
->addTemplateInfo()
->addSubscriberFilter(Mage::registry('subscriber')->getId());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/Orders.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_grid_collection')
->addFieldToSelect('entity_id')
->addFieldToSelect('increment_id')
->addFieldToSelect('customer_id')
->addFieldToSelect('created_at')
->addFieldToSelect('grand_total')
->addFieldToSelect('order_currency_code')
->addFieldToSelect('store_id')
->addFieldToSelect('billing_name')
->addFieldToSelect('shipping_name')
->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
->setIsCustomerMode(true);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/Tag.php
function _prepareCollection()
{
$tagId = Mage::registry('tagId');
if( $this->getCustomerId() instanceof Mage_Customer_Model_Customer ) {
$this->setCustomerId( $this->getCustomerId()->getId() );
}
$collection = Mage::getResourceModel('tag/customer_collection')
->addCustomerFilter($this->getCustomerId())
->addGroupByTag();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/Tags.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/View/Cart.php
function _prepareCollection()
{
$quote = Mage::getModel('sales/quote');
// set website to quote, if any
if ($this->getWebsiteId()) {
$quote->setWebsite(Mage::app()->getWebsite($this->getWebsiteId()));
}
$quote->loadByCustomer(Mage::registry('current_customer'));
if ($quote) {
$collection = $quote->getItemsCollection(false);
}
else {
$collection = new Varien_Data_Collection();
}
$collection->addFieldToFilter('parent_item_id', array('null' => true));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/View/Orders.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_grid_collection')
->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
->setIsCustomerMode(true);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php
function _prepareCollection()
{
$collection = Mage::getModel('wishlist/item')->getCollection()
->addCustomerIdFilter(Mage::registry('current_customer')->getId())
->addDaysInWishlist(true)
->addStoreData()
->setInStockFilter(true);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Edit/Tab/Wishlist.php
function _prepareCollection()
{
$collection = $this->_createCollection()->addCustomerIdFilter($this->_getCustomer()->getId())
->resetSortOrder()
->addDaysInWishlist()
->addStoreData();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Group/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/group_collection')
->addTaxClass();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Customer/Online/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('log/visitor_online')
->prepare()
->getCollection();
/* @var $collection Mage_Log_Model_Mysql4_Visitor_Online_Collection */
$collection->addCustomerData();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Orders/Grid.php
function _prepareCollection()
{
if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
return $this;
}
$collection = Mage::getResourceModel('reports/order_collection')
->addItemCountExpr()
->joinCustomerName('customer')
->orderByCreatedAt();
if($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
if ($this->getParam('store')) {
$collection->addAttributeToFilter('store_id', $this->getParam('store'));
} else if ($this->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
} else if ($this->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
}
$collection->addRevenueToSelect();
} else {
$collection->addRevenueToSelect(true);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Searches/Last.php
function _prepareCollection()
{
if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
return parent::_prepareCollection();
}
$this->_collection = Mage::getModel('catalogsearch/query')
->getResourceCollection();
$this->_collection->setRecentQueryFilter();
if ($this->getRequest()->getParam('store')) {
$this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
} else if ($this->getRequest()->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
} else if ($this->getRequest()->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
}
$this->setCollection($this->_collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Searches/Top.php
function _prepareCollection()
{
if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
return parent::_prepareCollection();
}
$this->_collection = Mage::getModel('catalogsearch/query')
->getResourceCollection();
if ($this->getRequest()->getParam('store')) {
$storeIds = $this->getRequest()->getParam('store');
} else if ($this->getRequest()->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
} else if ($this->getRequest()->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
} else {
$storeIds = '';
}
$this->_collection
->setPopularQueryFilter($storeIds);
$this->setCollection($this->_collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Tab/Customers/Most.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/order_collection');
/* @var $collection Mage_Reports_Model_Mysql4_Order_Collection */
$collection
->groupByCustomer()
->addOrdersCount()
->joinCustomerName();
$storeFilter = 0;
if ($this->getParam('store')) {
$collection->addAttributeToFilter('store_id', $this->getParam('store'));
$storeFilter = 1;
} else if ($this->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
} else if ($this->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
}
$collection->addSumAvgTotals($storeFilter)
->orderByTotalAmount();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Tab/Customers/Newest.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/customer_collection')
->addCustomerName();
$storeFilter = 0;
if ($this->getParam('store')) {
$collection->addAttributeToFilter('store_id', $this->getParam('store'));
$storeFilter = 1;
} else if ($this->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
} else if ($this->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
}
$collection->addOrdersStatistics($storeFilter)
->orderByCustomerRegistration();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Tab/Products/Ordered.php
function _prepareCollection()
{
if (!Mage::helper('core')->isModuleEnabled('Mage_Sales')) {
return $this;
}
if ($this->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else {
$storeId = (int)$this->getParam('store');
}
$collection = Mage::getResourceModel('sales/report_bestsellers_collection')
->setModel('catalog/product')
->addStoreFilter($storeId)
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Dashboard/Tab/Products/Viewed.php
function _prepareCollection()
{
if ($this->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else {
$storeId = (int)$this->getParam('store');
}
$collection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addViewsCount()
->setStoreId($storeId)
->addStoreFilter($storeId);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Newsletter/Problem/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('newsletter/problem_collection')
->addSubscriberInfo()
->addQueueInfo();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Newsletter/Queue/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('newsletter/queue_collection')
->addSubscribersInfo();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Newsletter/Subscriber/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceSingleton('newsletter/subscriber_collection');
/* @var $collection Mage_Newsletter_Model_Mysql4_Subscriber_Collection */
$collection
->showCustomerInfo(true)
->addSubscriberTypeField()
->showStoreInfo();
if($this->getRequest()->getParam('queue', false)) {
$collection->useQueue(Mage::getModel('newsletter/queue')
->load($this->getRequest()->getParam('queue')));
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Newsletter/Template/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceSingleton('newsletter/template_collection')
->useOnlyActual();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Notification/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('adminnotification/inbox')
->getCollection()
->addRemoveFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Permissions/Grid/Role.php
function _prepareCollection()
{
$collection = Mage::getModel("admin/roles")->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Permissions/Grid/User.php
function _prepareCollection()
{
$collection = Mage::getModel("permissions/users")->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Permissions/Role/Grid/User.php
function _prepareCollection()
{
$roleId = $this->getRequest()->getParam('rid');
Mage::register('RID', $roleId);
$collection = Mage::getModel('admin/roles')->getUsersCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Permissions/User/Edit/Tab/Roles.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('admin/role_collection');
$collection->setRolesFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Permissions/User/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('admin/user_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('poll/poll_answer')
->getResourceCollection()
->addPollFilter($this->getRequest()->getParam('id'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Poll/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('poll/poll')->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
if (!Mage::app()->isSingleStoreMode()) {
$this->getCollection()->addStoreData();
}
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Promo/Catalog/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_CatalogRule_Model_Mysql4_Rule_Collection */
$collection = Mage::getModel('catalogrule/rule')
->getResourceCollection();
$collection->addWebsitesToResult();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php
function _prepareCollection()
{
$priceRule = Mage::registry('current_promo_quote_rule');
/**
* @var Mage_SalesRule_Model_Resource_Coupon_Collection $collection
*/
$collection = Mage::getResourceModel('salesrule/coupon_collection')
->addRuleToFilter($priceRule)
->addGeneratedCouponsFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Promo/Quote/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_SalesRule_Model_Mysql4_Rule_Collection */
$collection = Mage::getModel('salesrule/rule')
->getResourceCollection();
$collection->addWebsitesToResult();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Promo/Widget/Chooser/Sku.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('catalog/product_collection')
->setStoreId(0)
->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Promo/Widget/Chooser.php
function _prepareCollection()
{
$collection = Mage::getModel('salesrule/rule')->getResourceCollection();
$this->setCollection($collection);
Mage::dispatchEvent('adminhtml_block_promo_widget_chooser_prepare_collection', array(
'collection' => $collection
));
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Rating/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('rating/rating')
->getResourceCollection()
->addEntityFilter(Mage::registry('entityId'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Customer/Accounts/Grid.php
function _prepareCollection()
{
parent::_prepareCollection();
$this->getCollection()->initReport('reports/accounts_collection');
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Customer/Orders/Grid.php
function _prepareCollection()
{
parent::_prepareCollection();
$this->getCollection()->initReport('reports/customer_orders_collection');
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Customer/Totals/Grid.php
function _prepareCollection()
{
parent::_prepareCollection();
$this->getCollection()->initReport('reports/customer_totals_collection');
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Grid/Abstract.php
function _prepareCollection()
{
$filterData = $this->getFilterData();
if ($filterData->getData('from') == null || $filterData->getData('to') == null) {
$this->setCountTotals(false);
$this->setCountSubTotals(false);
return parent::_prepareCollection();
}
$storeIds = $this->_getStoreIds();;
$orderStatuses = $filterData->getData('order_statuses');
if (is_array($orderStatuses)) {
if (count($orderStatuses) == 1 && strpos($orderStatuses[0],',')!== false) {
$filterData->setData('order_statuses', explode(',',$orderStatuses[0]));
}
}
$resourceCollection = Mage::getResourceModel($this->getResourceCollectionName())
->setPeriod($filterData->getData('period_type'))
->setDateRange($filterData->getData('from', null), $filterData->getData('to', null))
->addStoreFilter($storeIds)
->setAggregatedColumns($this->_getAggregatedColumns());
$this->_addOrderStatusFilter($resourceCollection, $filterData);
$this->_addCustomFilter($resourceCollection, $filterData);
if ($this->_isExport) {
$this->setCollection($resourceCollection);
return $this;
}
if ($filterData->getData('show_empty_rows', false)) {
Mage::helper('reports')->prepareIntervalsCollection(
$this->getCollection(),
$filterData->getData('from', null),
$filterData->getData('to', null),
$filterData->getData('period_type')
);
}
if ($this->getCountSubTotals()) {
$this->getSubTotals();
}
if ($this->getCountTotals()) {
$totalsCollection = Mage::getResourceModel($this->getResourceCollectionName())
->setPeriod($filterData->getData('period_type'))
->setDateRange($filterData->getData('from', null), $filterData->getData('to', null))
->addStoreFilter($storeIds)
->setAggregatedColumns($this->_getAggregatedColumns())
->isTotals(true);
$this->_addOrderStatusFilter($totalsCollection, $filterData);
$this->_addCustomFilter($totalsCollection, $filterData);
foreach ($totalsCollection as $item) {
$this->setTotals($item);
break;
}
}
$this->getCollection()->setColumnGroupBy($this->_columnGroupBy);
$this->getCollection()->setResourceCollection($resourceCollection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Grid.php
function _prepareCollection()
{
$filter = $this->getParam($this->getVarNameFilter(), null);
if (is_null($filter)) {
$filter = $this->_defaultFilter;
}
if (is_string($filter)) {
$data = array();
$filter = base64_decode($filter);
parse_str(urldecode($filter), $data);
if (!isset($data['report_from'])) {
// getting all reports from 2001 year
$date = new Zend_Date(mktime(0,0,0,1,1,2001));
$data['report_from'] = $date->toString($this->getLocale()->getDateFormat('short'));
}
if (!isset($data['report_to'])) {
// getting all reports from 2001 year
$date = new Zend_Date();
$data['report_to'] = $date->toString($this->getLocale()->getDateFormat('short'));
}
$this->_setFilterValues($data);
} else if ($filter && is_array($filter)) {
$this->_setFilterValues($filter);
} else if(0 !== sizeof($this->_defaultFilter)) {
$this->_setFilterValues($this->_defaultFilter);
}
/** @var $collection Mage_Reports_Model_Resource_Report_Collection */
$collection = Mage::getResourceModel('reports/report_collection');
$collection->setPeriod($this->getFilter('report_period'));
if ($this->getFilter('report_from') && $this->getFilter('report_to')) {
/**
* Validate from and to date
*/
try {
$from = $this->getLocale()->date($this->getFilter('report_from'), Zend_Date::DATE_SHORT, null, false);
$to = $this->getLocale()->date($this->getFilter('report_to'), Zend_Date::DATE_SHORT, null, false);
$collection->setInterval($from, $to);
}
catch (Exception $e) {
$this->_errors[] = Mage::helper('reports')->__('Invalid date specified.');
}
}
/**
* Getting and saving store ids for website & group
*/
$storeIds = array();
if ($this->getRequest()->getParam('store')) {
$storeIds = array($this->getParam('store'));
} elseif ($this->getRequest()->getParam('website')){
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
} elseif ($this->getRequest()->getParam('group')){
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
}
// By default storeIds array contains only allowed stores
$allowedStoreIds = array_keys(Mage::app()->getStores());
// And then array_intersect with post data for prevent unauthorized stores reports
$storeIds = array_intersect($allowedStoreIds, $storeIds);
// If selected all websites or unauthorized stores use only allowed
if (empty($storeIds)) {
$storeIds = $allowedStoreIds;
}
// reset array keys
$storeIds = array_values($storeIds);
$collection->setStoreIds($storeIds);
if ($this->getSubReportSize() !== null) {
$collection->setPageSize($this->getSubReportSize());
}
$this->setCollection($collection);
Mage::dispatchEvent('adminhtml_widget_grid_filter_collection',
array('collection' => $this->getCollection(), 'filter_values' => $this->_filterValues)
);
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Product/Downloads/Grid.php
function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
$collection = Mage::getResourceModel('reports/product_downloads_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addAttributeToFilter('type_id', array(Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE))
->addSummary();
if( $storeId ) {
$collection->addStoreFilter($storeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Product/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/product_collection');
$collection->getEntity()->setStore(0);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Product/Lowstock/Grid.php
function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
/** @var $collection Mage_Reports_Model_Resource_Product_Lowstock_Collection */
$collection = Mage::getResourceModel('reports/product_lowstock_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->filterByIsQtyProductTypes()
->joinInventoryItem('qty')
->useManageStockFilter($storeId)
->useNotifyStockQtyFilter($storeId)
->setOrder('qty', Varien_Data_Collection::SORT_ORDER_ASC);
if( $storeId ) {
$collection->addStoreFilter($storeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Product/Ordered/Grid.php
function _prepareCollection()
{
parent::_prepareCollection();
$this->getCollection()->initReport('reports/product_ordered_collection');
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Product/Sold/Grid.php
function _prepareCollection()
{
parent::_prepareCollection();
$this->getCollection()
->initReport('reports/product_sold_collection');
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Refresh/Statistics/Grid.php
function _prepareCollection()
{
$collection = new Varien_Data_Collection();
$data = array(
array(
'id' => 'sales',
'report' => Mage::helper('sales')->__('Orders'),
'comment' => Mage::helper('sales')->__('Total Ordered Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE)
),
array(
'id' => 'tax',
'report' => Mage::helper('sales')->__('Tax'),
'comment' => Mage::helper('sales')->__('Order Taxes Report Grouped by Tax Rates'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_TAX_FLAG_CODE)
),
array(
'id' => 'shipping',
'report' => Mage::helper('sales')->__('Shipping'),
'comment' => Mage::helper('sales')->__('Total Shipped Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE)
),
array(
'id' => 'invoiced',
'report' => Mage::helper('sales')->__('Total Invoiced'),
'comment' => Mage::helper('sales')->__('Total Invoiced VS Paid Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_INVOICE_FLAG_CODE)
),
array(
'id' => 'refunded',
'report' => Mage::helper('sales')->__('Total Refunded'),
'comment' => Mage::helper('sales')->__('Total Refunded Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_REFUNDED_FLAG_CODE)
),
array(
'id' => 'coupons',
'report' => Mage::helper('sales')->__('Coupons'),
'comment' => Mage::helper('sales')->__('Promotion Coupons Usage Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_COUPONS_FLAG_CODE)
),
array(
'id' => 'bestsellers',
'report' => Mage::helper('sales')->__('Bestsellers'),
'comment' => Mage::helper('sales')->__('Products Bestsellers Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_BESTSELLERS_FLAG_CODE)
),
array(
'id' => 'viewed',
'report' => Mage::helper('sales')->__('Most Viewed'),
'comment' => Mage::helper('sales')->__('Most Viewed Products Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE)
),
);
foreach ($data as $value) {
$item = new Varien_Object();
$item->setData($value);
$collection->addItem($item);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Review/Customer/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/review_customer_collection')
->joinCustomers();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Review/Detail/Grid.php
function _prepareCollection()
{
//$collection = Mage::getModel('review/review')->getProductCollection();
//$collection->getSelect()
// ->where('rt.entity_pk_value='.(int)$this->getRequest()->getParam('id'));
//$collection->getEntity()->setStore(0);
$collection = Mage::getResourceModel('reports/review_collection')
->addProductFilter((int)$this->getRequest()->getParam('id'));
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Review/Product/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/review_product_collection')
->joinReview();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Sales/Tax/Grid.php
function _prepareCollection()
{
$filterData = $this->getFilterData();
if(!$filterData->hasData('order_statuses')) {
$orderConfig = Mage::getModel('sales/order_config');
$statusValues = array();
$canceledStatuses = $orderConfig->getStateStatuses(Mage_Sales_Model_Order::STATE_CANCELED);
foreach ($orderConfig->getStatuses() as $code => $label) {
if (!isset($canceledStatuses[$code])) {
$statusValues[] = $code;
}
}
$filterData->setOrderStatuses($statusValues);
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Search/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('catalogsearch/query_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Shopcart/Abandoned/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_Reports_Model_Resource_Quote_Collection */
$collection = Mage::getResourceModel('reports/quote_collection');
$filter = $this->getParam($this->getVarNameFilter(), array());
if ($filter) {
$filter = base64_decode($filter);
parse_str(urldecode($filter), $data);
}
if (!empty($data)) {
$collection->prepareForAbandonedReport($this->_storeIds, $data);
} else {
$collection->prepareForAbandonedReport($this->_storeIds);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Shopcart/Customer/Grid.php
function _prepareCollection()
{
//TODO: add full name logic
$collection = Mage::getResourceModel('reports/customer_collection')
->addAttributeToSelect('firstname')
->addAttributeToSelect('lastname');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Shopcart/Product/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_Reports_Model_Resource_Quote_Collection */
$collection = Mage::getResourceModel('reports/quote_collection');
$collection->prepareForProductsInCarts()
->setSelectCountSqlType(Mage_Reports_Model_Resource_Quote_Collection::SELECT_COUNT_SQL_TYPE_CART);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Tag/Customer/Detail/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('tag/tag')
->getEntityCollection()
->joinAttribute('original_name', 'catalog_product/name', 'entity_id')
->addCustomerFilter($this->getRequest()->getParam('id'))
->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED)
->setDescOrder('DESC')
->addStoresVisibility()
->setActiveFilter()
->addGroupByTag()
->setRelationId();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Tag/Customer/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/tag_customer_collection');
$collection->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED)
->addGroupByCustomer()
->addTagedCount();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Tag/Popular/Detail/Grid.php
function _prepareCollection()
{
/* @var $collection Mage_Reports_Model_Resource_Tag_Customer_Collection */
$collection = Mage::getResourceModel('reports/tag_customer_collection');
$collection->addStatusFilter(Mage::getModel('tag/tag')->getApprovedStatus())
->addTagFilter($this->getRequest()->getParam('id'))
->addDescOrder()
->addProductName();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Tag/Popular/Grid.php
function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeId = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
} else if ($this->getRequest()->getParam('group')) {
$storeId = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
$collection = Mage::getResourceModel('reports/tag_collection')
->addPopularity($storeId)
->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Tag/Product/Detail/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/tag_product_collection');
$collection->addTagedCount()
->addProductFilter($this->getRequest()->getParam('id'))
->addStatusFilter(Mage::getModel('tag/tag')->getApprovedStatus())
->addStoresVisibility()
->setActiveFilter()
->addGroupByTag()
->setRelationId();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Tag/Product/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/tag_product_collection');
$collection->addUniqueTagedCount()
->addAllTagedCount()
->addStatusFilter(Mage::getModel('tag/tag')->getApprovedStatus())
->addGroupByProduct();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Report/Wishlist/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/wishlist_product_collection')
->addAttributeToSelect('entity_id')
->addAttributeToSelect('name')
->addWishlistCount();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Review/Grid.php
function _prepareCollection()
{
$model = Mage::getModel('review/review');
$collection = $model->getProductCollection();
if ($this->getProductId() || $this->getRequest()->getParam('productId', false)) {
$productId = $this->getProductId();
if (!$productId) {
$productId = $this->getRequest()->getParam('productId');
}
$this->setProductId($productId);
$collection->addEntityFilter($this->getProductId());
}
if ($this->getCustomerId() || $this->getRequest()->getParam('customerId', false)) {
$customerId = $this->getCustomerId();
if (!$customerId){
$customerId = $this->getRequest()->getParam('customerId');
}
$this->setCustomerId($customerId);
$collection->addCustomerFilter($this->getCustomerId());
}
if (Mage::registry('usePendingFilter') === true) {
$collection->addStatusFilter($model->getPendingStatus());
}
$collection->addStoreData();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Creditmemo/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Invoice/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/Create/Customer/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_regione', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
->joinField('store_name', 'core/store', 'name', 'store_id=store_id', null, 'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/Create/Search/Grid.php
function _prepareCollection()
{
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$collection = Mage::getModel('catalog/product')->getCollection();
$collection
->setStore($this->getStore())
->addAttributeToSelect($attributes)
->addAttributeToSelect('sku')
->addStoreFilter()
->addAttributeToFilter('type_id', array_keys(
Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
))
->addAttributeToSelect('gift_message_available');
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/Status/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_status_collection');
$collection->joinStates();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/View/Tab/Creditmemos.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->addFieldToSelect('entity_id')
->addFieldToSelect('created_at')
->addFieldToSelect('increment_id')
->addFieldToSelect('order_currency_code')
->addFieldToSelect('store_currency_code')
->addFieldToSelect('base_currency_code')
->addFieldToSelect('state')
->addFieldToSelect('grand_total')
->addFieldToSelect('base_grand_total')
->addFieldToSelect('billing_name')
->setOrderFilter($this->getOrder())
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/View/Tab/Invoices.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->addFieldToSelect('entity_id')
->addFieldToSelect('created_at')
->addFieldToSelect('order_id')
->addFieldToSelect('increment_id')
->addFieldToSelect('state')
->addFieldToSelect('grand_total')
->addFieldToSelect('base_grand_total')
->addFieldToSelect('store_currency_code')
->addFieldToSelect('base_currency_code')
->addFieldToSelect('order_currency_code')
->addFieldToSelect('billing_name')
->setOrderFilter($this->getOrder())
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Order/View/Tab/Shipments.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->addFieldToSelect('entity_id')
->addFieldToSelect('created_at')
->addFieldToSelect('increment_id')
->addFieldToSelect('total_qty')
->addFieldToSelect('shipping_name')
->setOrderFilter($this->getOrder())
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Shipment/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Transactions/Child/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_payment_transaction_collection');
$collection->addParentIdFilter(Mage::registry('current_transaction')->getId());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Transactions/Detail/Grid.php
function _prepareCollection()
{
$collection = new Varien_Data_Collection();
foreach ($this->getTransactionAdditionalInfo() as $key => $value) {
$data = new Varien_Object(array('key' => $key, 'value' => $value));
$collection->addItem($data);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sales/Transactions/Grid.php
function _prepareCollection()
{
$collection = ($this->getCollection())
? $this->getCollection() : Mage::getResourceModel('sales/order_payment_transaction_collection');
$order = Mage::registry('current_order');
if ($order) {
$collection->addOrderIdFilter($order->getId());
}
$collection->addOrderInformation(array('increment_id'));
$collection->addPaymentInformation(array('method'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Shipping/Carrier/Tablerate/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection */
$collection = Mage::getResourceModel('shipping/carrier_tablerate_collection');
$collection->setConditionFilter($this->getConditionName())
->setWebsiteFilter($this->getWebsiteId());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Sitemap/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('sitemap/sitemap')->getCollection();
/* @var $collection Mage_Sitemap_Model_Mysql4_Sitemap_Collection */
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Convert/Gui/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('dataflow/profile_collection')
->addFieldToFilter('entity_type', array('notnull'=>''));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Convert/Profile/Edit/Tab/History.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('dataflow/profile_history_collection')
->joinAdminUser()
->addFieldToFilter('profile_id', Mage::registry('current_convert_profile')->getId());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Convert/Profile/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('dataflow/profile_collection')
->addFieldToFilter('entity_type', array('null'=>''));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Design/Grid.php
function _prepareCollection()
{
$storeId = (int) $this->getRequest()->getParam('store', 0);
$collection = Mage::getResourceModel('core/design_collection');
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Email/Template/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceSingleton('core/email_template_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Store/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('core/website')
->getCollection()
->joinGroupAndStore();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/System/Variable/Grid.php
function _prepareCollection()
{
/* @var $collection Mage_Core_Model_Mysql4_Variable_Collection */
$collection = Mage::getModel('core/variable')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Assigned/Grid.php
function _prepareCollection()
{
$store = $this->_getStore();
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id')
//->addAttributeToFilter('status', array(''))
->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
if ($store->getId()) {
$collection->addStoreFilter($store);
$collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
$collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
} else {
$collection->addAttributeToSelect('price');
$collection->addAttributeToSelect('status');
$collection->addAttributeToSelect('visibility');
}
$this->setCollection($collection);
parent::_prepareCollection();
$this->getCollection()->addWebsiteNamesToResult();
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Customer/Grid.php
function _prepareCollection()
{
$tagId = Mage::registry('current_tag')->getId();
$storeId = Mage::registry('current_tag')->getStoreId();
$collection = Mage::getModel('tag/tag')
->getCustomerCollection()
->addTagFilter($tagId)
->setCountAttribute('tr.tag_relation_id')
->addStoreFilter($storeId)
->addGroupByCustomerProduct();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Grid/All.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('tag/tag_collection')
// ->addStoreFilter(Mage::app()->getStore()->getId())
->addStoresVisibility()
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Grid/Customers.php
function _prepareCollection()
{
//TODO: add full name logic
$collection = Mage::getResourceModel('tag_customer/collection')
->addAttributeToSelect('firstname')
->addAttributeToSelect('lastname')
// ->addAttributeToSelect('email')
// ->addAttributeToSelect('created_at')
// ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing')
// ->joinAttribute('billing_city', 'customer_address/city', 'default_billing')
// ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing')
// ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing')
// ->joinField('billing_country_name', 'directory/country_name', 'name', 'country_id=billing_country_id', array('language_code'=>'en'))
;
if ($productId = $this->getRequest()->getParam('product_id')) {
$collection->addProductFilter($productId);
}
if ($tagId = $this->getRequest()->getParam('tag_id')) {
$collection->addTagFilter($tagId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Grid/Pending.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('tag/tag_collection')
->addSummary(0)
->addStoresVisibility()
->addStatusFilter(Mage_Tag_Model_Tag::STATUS_PENDING);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Grid/Products.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('tag/product_collection')
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
;
if ($tagId = $this->getRequest()->getParam('tag_id')) {
$collection->addTagFilter($tagId);
}
if ($customerId = $this->getRequest()->getParam('customer_id')) {
$collection->addCustomerFilter($customerId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Product/Grid.php
function _prepareCollection()
{
$tagId = Mage::registry('current_tag')->getId();
$storeId = Mage::registry('current_tag')->getStoreId();
$collection = Mage::getModel('tag/tag')
->getEntityCollection()
->addTagFilter($tagId)
->addCustomerFilter(array('null' => false))
->addStoreFilter($storeId)
->addPopularity($tagId);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tag/Tag/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('tag/tag_collection')
->addSummary(Mage::app()->getStore()->getId())
->addStoresVisibility();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tax/Class/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('tax/class')
->getCollection()
->setClassTypeFilter($this->getClassType());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tax/Rate/Grid.php
function _prepareCollection()
{
$rateCollection = Mage::getModel('tax/calculation_rate')->getCollection()
->joinRegionTable();
$this->setCollection($rateCollection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Tax/Rule/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('tax/calculation_rule')
->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
if ($this->getCollection()) {
$this->getCollection()
->addCustomerTaxClassesToResult()
->addProductTaxClassesToResult()
->addRatesToResult();
}
return $this;
}
+--------------------------------------------------+
File: Adminhtml/Block/Urlrewrite/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('core/url_rewrite_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Widget/Grid.php
function _prepareCollection()
{
if ($this->getCollection()) {
$this->_preparePage();
$columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
$dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir);
$filter = $this->getParam($this->getVarNameFilter(), null);
if (is_null($filter)) {
$filter = $this->_defaultFilter;
}
if (is_string($filter)) {
$data = $this->helper('adminhtml')->prepareFilterString($filter);
$this->_setFilterValues($data);
}
else if ($filter && is_array($filter)) {
$this->_setFilterValues($filter);
}
else if(0 !== sizeof($this->_defaultFilter)) {
$this->_setFilterValues($this->_defaultFilter);
}
if (isset($this->_columns[$columnId]) && $this->_columns[$columnId]->getIndex()) {
$dir = (strtolower($dir)=='desc') ? 'desc' : 'asc';
$this->_columns[$columnId]->setDir($dir);
$this->_setCollectionOrder($this->_columns[$columnId]);
}
if (!$this->_isExport) {
$this->getCollection()->load();
$this->_afterLoadCollection();
}
}
return $this;
}
+--------------------------------------------------+
File: Api2/Block/Adminhtml/Attribute/Grid.php
function _prepareCollection()
{
$collection = new Varien_Data_Collection();
foreach (Mage_Api2_Model_Auth_User::getUserTypes() as $type => $label) {
$collection->addItem(
new Varien_Object(array('user_type_name' => $label, 'user_type_code' => $type))
);
}
$this->setCollection($collection);
}
+--------------------------------------------------+
File: Api2/Block/Adminhtml/Permissions/User/Edit/Tab/Roles.php
function _prepareCollection()
{
/** @var $collection Mage_Api2_Model_Resource_Acl_Global_Role_Collection */
$collection = Mage::getResourceModel('api2/acl_global_role_collection');
$collection->addFieldToFilter('entity_id', array('nin' => Mage_Api2_Model_Acl_Global_Role::getSystemRoles()));
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Api2/Block/Adminhtml/Roles/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_Api2_Model_Resource_Acl_Global_Role_Collection */
$collection = Mage::getModel('api2/acl_global_role')->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Api2/Block/Adminhtml/Roles/Tab/Users.php
function _prepareCollection()
{
/** @var $collection Mage_Admin_Model_Resource_User_Collection */
$collection = Mage::getModel('admin/user')->getCollection();
$collection->getSelect()->joinLeft(
array('acl' => $collection->getTable('api2/acl_user')),
'acl.admin_id = main_table.user_id',
'role_id'
);
if ($this->getRole() && $this->getRole()->getId()) {
$collection->addFilter('acl.role_id', $this->getRole()->getId());
}
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection()
->setStore($this->getStore())
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('price')
->addAttributeToSelect('attribute_set_id')
->addAttributeToFilter('type_id', array('in' => $this->getAllowedSelectionTypes()))
->addFilterByRequiredOptions()
->addStoreFilter();
if ($products = $this->_getProducts()) {
$collection->addIdFilter($this->_getProducts(), true);
}
if ($this->getFirstShow()) {
$collection->addIdFilter('-1');
$this->setEmptyText($this->__('Please enter search conditions to view products.'));
}
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Catalog/Block/Seo/Sitemap/Tree/Category.php
function _prepareCollection()
{
$_to = 0;
$pathFilter = array();
if (isset($this->_categoriesToPages[$this->_currentPage])) {
foreach ($this->_categoriesToPages[$this->_currentPage] as $_categoryId=>$_categoryInfo) {
$pathFilter[] = $_categoryInfo['path'];
$_to = max($_to, $_categoryInfo['children_count']);
}
}
if (empty($pathFilter)) {
$pathFilter = $this->_storeRootCategoryPath . '/';
}
$collection = $this->getCollection();
$collection->addPathsFilter($pathFilter);
$this->_to = $_to;
$this->_from = $_to - $collection->count();
return $this;
}
+--------------------------------------------------+
File: Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php
function _prepareCollection()
{
$this->setCollection($this->getCollection());
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: GoogleBase/Block/Adminhtml/Items/Item.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('googlebase/item_collection');
$store = $this->_getStore();
$collection->addStoreFilterId($store->getId());
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: GoogleBase/Block/Adminhtml/Items/Product.php
function _prepareCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection()
->setStore($this->_getStore())
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('price')
->addAttributeToSelect('attribute_set_id');
// ->addFilterByRequiredOptions();
$store = $this->_getStore();
if ($store->getId()) {
$collection->addStoreFilter($store);
}
if ($excludeIds = $this->_getGoogleBaseProductIds()) {
$collection->addIdFilter($excludeIds, true);
}
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: GoogleBase/Block/Adminhtml/Types/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('googlebase/type_collection')->addItemsCount();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Index/Block/Adminhtml/Process/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('index/process_collection');
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Oauth/Block/Adminhtml/Oauth/Admin/Token/Grid.php
function _prepareCollection()
{
/** @var $user Mage_Admin_Model_User */
$user = Mage::getSingleton('admin/session')->getData('user');
/** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
$collection = Mage::getModel('oauth/token')->getCollection();
$collection->joinConsumerAsApplication()
->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)
->addFilterByAdminId($user->getId());
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php
function _prepareCollection()
{
/** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
$collection = Mage::getModel('oauth/token')->getCollection();
$collection->joinConsumerAsApplication()
->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS);
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
+--------------------------------------------------+
File: Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('oauth/consumer')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Paypal/Block/Adminhtml/Settlement/Report/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('paypal/report_settlement_row_collection');
$this->setCollection($collection);
if (!$this->getParam($this->getVarNameSort())) {
$collection->setOrder('row_id', 'desc');
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Sales/Block/Adminhtml/Billing/Agreement/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/billing_agreement_collection')
->addCustomerDetails();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_grid_collection');
$collection->addBillingAgreementsFilter(Mage::registry('current_billing_agreement')->getId());
$this->setCollection($collection);
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
}
+--------------------------------------------------+
File: Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/billing_agreement_collection')
->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
->setOrder('created_at');
$this->setCollection($collection);
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
}
+--------------------------------------------------+
File: Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/recurring_profile_collection')
->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId());
if (!$this->getParam($this->getVarNameSort())) {
$collection->setOrder('profile_id', 'desc');
}
$this->setCollection($collection);
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
}
+--------------------------------------------------+
File: Sales/Block/Adminhtml/Recurring/Profile/Grid.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/recurring_profile_collection');
$this->setCollection($collection);
if (!$this->getParam($this->getVarNameSort())) {
$collection->setOrder('profile_id', 'desc');
}
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('sales/order_grid_collection')
->addRecurringProfilesFilter(Mage::registry('current_recurring_profile')->getId())
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Widget/Block/Adminhtml/Widget/Instance/Grid.php
function _prepareCollection()
{
/* @var $collection Mage_Widget_Model_Mysql4_Widget_Instance_Collection */
$collection = Mage::getModel('widget/widget_instance')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Wishlist/Block/Abstract.php
function _prepareCollection($collection)
{
return $this;
}
+--------------------------------------------------+
File: Wishlist/Block/Customer/Sidebar.php
function _prepareCollection($collection)
{
$collection->setCurPage(1)
->setPageSize(3)
->setInStockFilter(true)
->setOrder('added_at');
return $this;
}
+--------------------------------------------------+
File: Wishlist/Block/Customer/Wishlist.php
function _prepareCollection($collection)
{
$collection->setInStockFilter(true)->setOrder('added_at', 'ASC');
return $this;
}
+--------------------------------------------------+
File: XmlConnect/Block/Adminhtml/History/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('xmlconnect/history')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: XmlConnect/Block/Adminhtml/Mobile/Edit/Tab/Submission/History.php
function _prepareCollection()
{
$collection = Mage::getResourceModel('xmlconnect/history_collection')
->addApplicationFilter($this->_getApplication()->getId());
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: XmlConnect/Block/Adminhtml/Mobile/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('xmlconnect/application')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: XmlConnect/Block/Adminhtml/Queue/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('xmlconnect/queue')->getCollection();
$collection->addFieldToFilter(
'main_table.status',
array('neq' => Mage_XmlConnect_Model_Queue::STATUS_DELETED)
);
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: XmlConnect/Block/Adminhtml/Template/Grid.php
function _prepareCollection()
{
$collection = Mage::getModel('xmlconnect/template')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: XmlConnect/Block/Catalog/Product/List.php
function _prepareCollection($collection)
{
/**
* Apply sort params
*/
$reguest = $this->getRequest();
foreach ($reguest->getParams() as $key => $value) {
if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX)) {
$key = str_replace(parent::REQUEST_SORT_ORDER_PARAM_REFIX, '', $key);
if ($value != 'desc') {
$value = 'asc';
}
$collection->addAttributeToSort($key, $value);
}
}
$collection->addAttributeToSelect(array('image', 'name', 'description'));
return $this;
}
+--------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment