Skip to content

Instantly share code, notes, and snippets.

@anthuanvasquez
Last active January 12, 2019 01:26
Show Gist options
  • Save anthuanvasquez/a4a311a3dc410f975df5e5b3306a6867 to your computer and use it in GitHub Desktop.
Save anthuanvasquez/a4a311a3dc410f975df5e5b3306a6867 to your computer and use it in GitHub Desktop.
Magento Get Products by Category ID
<?php
$_categoryId = 123;
$_limit = 10;
$_categoryModel = Mage::getModel('catalog/category');
$_category = $_categoryModel->load($_categoryId);
$_productCollection = $_category->getProductCollection()
->addAttributeToSelect('*')
->setPage(1, $_limit);
if ($_products->getSize()) {
foreach ($_products as $_product) {
var_dump($_product->getData());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment