Magento – how to count all products with php – Magento product collection model?

You wonder how many products you have in your store and want to count them trough PHP code? It's easy, add following code to test.php (create in root folder):

PHP:
  1. require_once 'app/Mage.php'; Mage::run();
  2. echo Mage::getResourceModel('catalog/product_collection')->count(); // count all products
  3. echo Mage::getResourceModel('catalog/product_collection')->addCategoryFilter(Mage::getModel('catalog/category')->load(113))->count(); // count products in defind category 113

Podobni članki:

  1. Magento – how to call template or block inside category or other view
  2. Magento slow product save and update
  3. Magento – uvoz večnivojskih kategorij
  4. Magento – add custom category attribute, show top categories
  5. Magento – working with queries
  6. Magento massive products import with database query
  7. Magento override model
  8. Magento – razvoj novih modulov – debugiranje
  9. Magento – ali lahko uporabim šumnike v imenu, opisu ter URL-ju produkta?
  10. Magento – how to remove product gallery images

Dodaj komentar