Skip to main content
code format
Source Link
Marius
  • 198.5k
  • 55
  • 424
  • 833

for example In my store 10 products with different categories .I need information for each one product like this array(product_id=>1, name=>abc, product_categories=>1,2,3, price=>10.00, position of product=>1 ) similarly

array(product_id=>1,
      name=>abc,
      product_categories=>1,2,3,
      price=>10.00,
      position of product=>1
)

similarly I want all products.please help.I tried all ways and solution that are on google. Below is the code to get all products with their categories but position field not getting.

  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSort('position');
              $prodIds=$products->getAllIds();
              if(count($prodIds)>0)
              {
                  $product = Mage::getModel('catalog/product');
                   $i=0;
                  foreach($prodIds as $productId)
                  {
                        $ids= array();
                        $productCollection = Mage::getModel('catalog/product')->load($productId);
                        $final['prodCat_list'][$i]['sku']= $productCollection ->getSku();
                        $final['prodCat_list'][$i]['product_id']= $productId;
                        $final['prodCat_list'][$i]['name']= $productCollection ->getName();
                        $final['prodCat_list'][$i]['image']=$productCollection ->getThumbnailUrl(); 
                        $final['prodCat_list'][$i]['description']=$productCollection ->getDescription();
                        $final['prodCat_list'][$i]['short_description']=$productCollection ->getShortDescription();
                        $final['prodCat_list'][$i]['weight']=$productCollection ->getWeight();
                        $final['prodCat_list'][$i]['created_at']=$productCollection ->getCreatedAt();
                        $final['prodCat_list'][$i]['updated_at']=$productCollection ->getUpdatedAt();
                        $final['prodCat_list'][$i]['price']=$productCollection ->getPrice();
                        $final['prodCat_list'][$i]['special_price']=$productCollection ->getSpecialPrice();
                        $final['prodCat_list'][$i]['tax_class_id']=$productCollection ->getTaxClassId();
                        $final['prodCat_list'][$i]['cat_id']= implode(',',$productCollection ->getCategoryIds());
                        $ids[$i]=$result[$i]['category_ids'];
                        foreach($productCollection ->getCategoryIds() as $categoryId)
                        {
                          $category = Mage::getModel('catalog/category')->load($categoryId);
                          $final['prodCat_list'][$i]['cat_name'][$categoryId]= $category->getName();
                        }
                       $i++;
                  }
}

for example In my store 10 products with different categories .I need information for each one product like this array(product_id=>1, name=>abc, product_categories=>1,2,3, price=>10.00, position of product=>1 ) similarly I want all products.please help.I tried all ways and solution that are on google. Below is the code to get all products with their categories but position field not getting.

  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSort('position');
              $prodIds=$products->getAllIds();
              if(count($prodIds)>0)
              {
                  $product = Mage::getModel('catalog/product');
                   $i=0;
                  foreach($prodIds as $productId)
                  {
                        $ids= array();
                        $productCollection = Mage::getModel('catalog/product')->load($productId);
                        $final['prodCat_list'][$i]['sku']= $productCollection ->getSku();
                        $final['prodCat_list'][$i]['product_id']= $productId;
                        $final['prodCat_list'][$i]['name']= $productCollection ->getName();
                        $final['prodCat_list'][$i]['image']=$productCollection ->getThumbnailUrl(); 
                        $final['prodCat_list'][$i]['description']=$productCollection ->getDescription();
                        $final['prodCat_list'][$i]['short_description']=$productCollection ->getShortDescription();
                        $final['prodCat_list'][$i]['weight']=$productCollection ->getWeight();
                        $final['prodCat_list'][$i]['created_at']=$productCollection ->getCreatedAt();
                        $final['prodCat_list'][$i]['updated_at']=$productCollection ->getUpdatedAt();
                        $final['prodCat_list'][$i]['price']=$productCollection ->getPrice();
                        $final['prodCat_list'][$i]['special_price']=$productCollection ->getSpecialPrice();
                        $final['prodCat_list'][$i]['tax_class_id']=$productCollection ->getTaxClassId();
                        $final['prodCat_list'][$i]['cat_id']= implode(',',$productCollection ->getCategoryIds());
                        $ids[$i]=$result[$i]['category_ids'];
                        foreach($productCollection ->getCategoryIds() as $categoryId)
                        {
                          $category = Mage::getModel('catalog/category')->load($categoryId);
                          $final['prodCat_list'][$i]['cat_name'][$categoryId]= $category->getName();
                        }
                       $i++;
                  }

for example In my store 10 products with different categories .I need information for each one product like this

array(product_id=>1,
      name=>abc,
      product_categories=>1,2,3,
      price=>10.00,
      position of product=>1
)

similarly I want all products.please help.I tried all ways and solution that are on google. Below is the code to get all products with their categories but position field not getting.

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSort('position');
$prodIds=$products->getAllIds();
if(count($prodIds)>0)
{
     $product = Mage::getModel('catalog/product');
     $i=0;
     foreach($prodIds as $productId)
     {
         $ids= array();
         $productCollection = Mage::getModel('catalog/product')->load($productId);
         $final['prodCat_list'][$i]['sku']= $productCollection ->getSku();
         $final['prodCat_list'][$i]['product_id']= $productId;
         $final['prodCat_list'][$i]['name']= $productCollection ->getName();
         $final['prodCat_list'][$i]['image']=$productCollection ->getThumbnailUrl(); 
         $final['prodCat_list'][$i]['description']=$productCollection ->getDescription();
         $final['prodCat_list'][$i]['short_description']=$productCollection ->getShortDescription();
         $final['prodCat_list'][$i]['weight']=$productCollection ->getWeight();
         $final['prodCat_list'][$i]['created_at']=$productCollection ->getCreatedAt();
         $final['prodCat_list'][$i]['updated_at']=$productCollection ->getUpdatedAt();
         $final['prodCat_list'][$i]['price']=$productCollection ->getPrice();
         $final['prodCat_list'][$i]['special_price']=$productCollection ->getSpecialPrice();
         $final['prodCat_list'][$i]['tax_class_id']=$productCollection ->getTaxClassId();
         $final['prodCat_list'][$i]['cat_id']= implode(',',$productCollection ->getCategoryIds());
         $ids[$i]=$result[$i]['category_ids'];
         foreach($productCollection ->getCategoryIds() as $categoryId)
         {
             $category = Mage::getModel('catalog/category')->load($categoryId);
             $final['prodCat_list'][$i]['cat_name'][$categoryId]= $category->getName();
         }
         $i++;
     }
}
Source Link
ZOE RULE
  • 141
  • 4
  • 14

How can get all products of magento estore with their position

I am getting all products of a magento estore with fields like sku,product_id,price,special_price and product categories . but I am not getting product position field. I want to get all products with their positions and categories so that products showing according to magento store on basis of position also same show on POS app.

for example In my store 10 products with different categories .I need information for each one product like this array(product_id=>1, name=>abc, product_categories=>1,2,3, price=>10.00, position of product=>1 ) similarly I want all products.please help.I tried all ways and solution that are on google. Below is the code to get all products with their categories but position field not getting.

  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSort('position');
              $prodIds=$products->getAllIds();
              if(count($prodIds)>0)
              {
                  $product = Mage::getModel('catalog/product');
                   $i=0;
                  foreach($prodIds as $productId)
                  {
                        $ids= array();
                        $productCollection = Mage::getModel('catalog/product')->load($productId);
                        $final['prodCat_list'][$i]['sku']= $productCollection ->getSku();
                        $final['prodCat_list'][$i]['product_id']= $productId;
                        $final['prodCat_list'][$i]['name']= $productCollection ->getName();
                        $final['prodCat_list'][$i]['image']=$productCollection ->getThumbnailUrl(); 
                        $final['prodCat_list'][$i]['description']=$productCollection ->getDescription();
                        $final['prodCat_list'][$i]['short_description']=$productCollection ->getShortDescription();
                        $final['prodCat_list'][$i]['weight']=$productCollection ->getWeight();
                        $final['prodCat_list'][$i]['created_at']=$productCollection ->getCreatedAt();
                        $final['prodCat_list'][$i]['updated_at']=$productCollection ->getUpdatedAt();
                        $final['prodCat_list'][$i]['price']=$productCollection ->getPrice();
                        $final['prodCat_list'][$i]['special_price']=$productCollection ->getSpecialPrice();
                        $final['prodCat_list'][$i]['tax_class_id']=$productCollection ->getTaxClassId();
                        $final['prodCat_list'][$i]['cat_id']= implode(',',$productCollection ->getCategoryIds());
                        $ids[$i]=$result[$i]['category_ids'];
                        foreach($productCollection ->getCategoryIds() as $categoryId)
                        {
                          $category = Mage::getModel('catalog/category')->load($categoryId);
                          $final['prodCat_list'][$i]['cat_name'][$categoryId]= $category->getName();
                        }
                       $i++;
                  }