I'm using the Milople Personalized Products Modules that creates a custom product type called "Milople Personalized Product" and I need to display a list of this products under a category id. I have tryed using this code:

$cat_id = 3;
$category = Mage::getModel('catalog/category')->load($cat_id);
$collection = $category->getProductCollection()->addAttributeToSort('position');

And it works form all default product types that come with magento except for the personalized ones.

  • What do you mean by custom product type? – Mujahidh Mar 9 '16 at 11:25
  • Sorry if its not the right name for it. From where I see it magento as "Simple Product", "Grouped Product", etc.. and the Milople Module creates a new product type called "Milople Personalized Product". I hope that explains what I mean by custom product type – sousatg Mar 9 '16 at 11:28

If it's a new product type, try to filter it in the collection:

   $collection = $category->getProductCollection()->addAttributeToSort('position')
->addAttributeToFilter('type_id', array('eq' => 'Milople Personalized Product'));

Hope this is what you want.


Try this:

$category = new Mage_Catalog_Model_Category(); 
$category->load(3); //this is category id 
$collection =
array('eq' => 'Milople Personalized Product'));
  • I have already tried this, it returns a empty collection. – sousatg Mar 9 '16 at 12:29
  • After getting the $collection I use foreach ($collection as $product): but theres still no product listed. Why does Magento tempalting has to be so complicated? – sousatg Mar 9 '16 at 12:35
  • Try to load the collection like this. If not, its an error when you catch the collection, becouse this must work – ntzz Mar 9 '16 at 14:23

Below code is export all product by category into csv .


require_once '../app/Mage.php';

$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();

$ids = $tree->getCollection()->getAllIds();
$fp = fopen('category-product-export.csv', 'w');
$field = array('Product SKU','Category Name'); 
fputcsv($fp, $field);

$_productCollection = Mage::getModel('catalog/product')
                        ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)

foreach ($_productCollection as $_product){
   $cats = $_product->getCategoryIds();
   $cnt = 0;
   $catName = '';
    foreach($cats as $id) {
        $root = 'Root Catalog';
            $isRoot = strtolower($root);
            $categoryName = strtolower($category->getName());
            if($categoryName == $isRoot){
        $categories[$id]['name'] = $category->getName();
        $categories[$id]['path'] = $category->getPath();

        $path = explode('/', $categories[$id]['path']);
        $len = count($path);
        $string = '';
        if($id > 2){
            foreach ($path as $k=>$pathId)
                $separator = '';
                if($pathId > 2){
                    if($k != $len-1){ $separator = ' || ';}
                    $string.= $category->getName() . $separator;

            if($cnt > 0) {
                $catName.= ','.$string;
            } else {
                $catName = $string;

    //echo $catName;
    $field = array($_product->getSku(),$catName); 
    fputcsv($fp, $field);   


<a href="category-product-export.csv">Download</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.