Skip to content

Instantly share code, notes, and snippets.

@fballiano
Last active January 21, 2018 11:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fballiano/6f73f3dff1cec9a42ef7 to your computer and use it in GitHub Desktop.
Save fballiano/6f73f3dff1cec9a42ef7 to your computer and use it in GitHub Desktop.
Magento product collections, general loading
<?php
$store_id = Mage::app()->getStore()->getId();
$collection = Mage::getModel("catalog/product")->getCollection();
$collection->setStoreId($store_id);
$collection->addStoreFilter($store_id);
//$collection->addAttributeToSelect("*");
$collection->addAttributeToFilter('status', array('in' => array(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)));
$collection->addAttributeToFilter('visibility', array('in '=> array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
Mage::getSingleton("cataloginventory/stock")->addInStockFilterToCollection($collection);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment