Skip to content

Instantly share code, notes, and snippets.

@fballiano
Last active January 21, 2018 11:17
Show Gist options
  • 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