Search
 
SCRIPT & CODE EXAMPLE
 

PHP

magento 1.9 get all product

//to overwrite limit but you need first to increase your memory limit

 $collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*') // select all attributes
->setPageSize(5000) // limit number of results returned
->setCurPage(1); // set the offset (useful for pagination)

// we iterate through the list of products to get attribute values
foreach ($collection as $product) {
  echo $product->getName(); //get name
  echo (float) $product->getPrice(); //get price as cast to float
  echo $product->getDescription(); //get description
  echo $product->getShortDescription(); //get short description
  echo $product->getTypeId(); //get product type
  echo $product->getStatus(); //get product status

  // getCategoryIds(); returns an array of category IDs associated with the product
  foreach ($product->getCategoryIds() as $category_id) {
      $category = Mage::getModel('catalog/category')->load($category_id);
      echo $category->getName();
      echo $category->getParentCategory()->getName(); // get parent of category
  }
  //gets the image url of the product
  echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
      'catalog/product'.$product->getImage();
  echo $product->getSpecialPrice();
  echo $product->getProductUrl();  //gets the product url
  echo '<br />';
}
Comment

magento 1.9 get all product

//to overwrite limit but you need first to increase your memory limit

 $collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*') // select all attributes
->setPageSize(5000) // limit number of results returned
->setCurPage(1); // set the offset (useful for pagination)

// we iterate through the list of products to get attribute values
foreach ($collection as $product) {
  echo $product->getName(); //get name
  echo (float) $product->getPrice(); //get price as cast to float
  echo $product->getDescription(); //get description
  echo $product->getShortDescription(); //get short description
  echo $product->getTypeId(); //get product type
  echo $product->getStatus(); //get product status

  // getCategoryIds(); returns an array of category IDs associated with the product
  foreach ($product->getCategoryIds() as $category_id) {
      $category = Mage::getModel('catalog/category')->load($category_id);
      echo $category->getName();
      echo $category->getParentCategory()->getName(); // get parent of category
  }
  //gets the image url of the product
  echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
      'catalog/product'.$product->getImage();
  echo $product->getSpecialPrice();
  echo $product->getProductUrl();  //gets the product url
  echo '<br />';
}
Comment

PREVIOUS NEXT
Code Example
Php :: global variable in laravel controller 
Php :: laravel pivot table model 
Php :: install bcmath php 7.3 ubuntu 
Php :: in array php 
Php :: laravel datatable render html 
Php :: $_server php 
Php :: execute script php command line 
Php :: laravel PageController.php 
Php :: Using the PHPExcel library to read an Excel file and transfer the data into a database 
Php :: php get array key 
Php :: laravel casts AsCollection 
Php :: php namespace class 
Php :: resize image using intervention laravel and save 
Php :: simple pagination in php 
Php :: transient wp 
Php :: How do I log properly a Laravel Job 
Php :: laravel run schedule only on production 
Php :: laravel how to nested foreach 
Php :: SUM with Eloquent 
Php :: license_verify 
Php :: A Livewire component was not found 
Php :: how to login first before see index php 
Php :: how to disable screenshot jquery 
Php :: download pdf file from database in php 
Php :: install composer laravel 
Php :: err_cache_miss php 
Php :: how to removde product into shop loop via product id 
Php :: codeigniter number format function 
Php :: phpspreadsheet select sheet 
Php :: Get the current script file name 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =