Created
January 6, 2015 09:02
-
-
Save werring/1508b80ac3e7df83596d to your computer and use it in GitHub Desktop.
Magento Category Collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @author T. Werring [email protected] | |
| * @project MagentoVPS | |
| * @created 30/12/14 16:57 | |
| */ | |
| require_once 'app/Mage.php'; | |
| /** | |
| * Error reporting | |
| */ | |
| error_reporting(E_ALL | E_STRICT); | |
| ini_set('display_errors', 1); | |
| $app = Mage::app(); | |
| for($i=3;$i<=4;$i++){ | |
| $category = Mage::getModel('catalog/category')->load($i); | |
| if($category->getLevel() > 1) continue; | |
| $collection = Mage::getResourceModel('catalog/product_collection') | |
| ->setStoreId($app->getStore()->getId()) | |
| ->addCategoryFilter($category)->addAttributeToFilter('status', array('eq' => 1)); | |
| printf("%s (%d)=>%s<br/>",$category->getName(),$i,$collection->count()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment