1

I have spent hours trying to find how to get a simple thing like all products - including the disabled ones.

My apologies , this is such an old version! I have looked up most of the posts on stack exchange etc to do this. the closest I have got is This post

In my code below , $products and $allProducts give me exactly the same amount , leaving out 200+ disabled products.

  • This is Magento 1.3

  • I do have flat catalog product & category switched on , and I want to run this script fairly regularly and don't want to have to switch it off.

  • I have read several other stack overflow etc. posts that don't work either.

Any Ideas how I can get all products in Magento 1.3 including the disabled ones?

<?php

header('Content-Type: application/json');
error_reporting(E_ALL);
ini_set("display_errors", 1);

require_once('./app/Mage.php');
Mage::app();

$storeId = Mage::app()->getStore()->getId();

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToSort('created_at', 'DESC')
    ->load();



$allProducts = Mage::getResourceModel('catalog/product_collection');

echo $products->getSize();
echo $allProducts->getSize();

?>
2

Try following way:


$newStoreId = Mage_Core_Model_App::ADMIN_STORE_ID;
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load($newStoreId));

$productCollection = $category->getProductCollection()->addAttributeToSelect('*');

Now you will able to get all products. But one problem here, that is product url. So use following code if you need url as well:


Mage::app()->setCurrentStore('default');
foreach ($productCollection as $product) {

}
  • I can't thank you enough! I did need to change the code because I am not using a category ( so you may want to change your answer ) , but it does the job in Magento 1.3. thanks. – Martin Thompson Apr 14 '18 at 7:46
2

Try to use this code. You'll get disabled product collection using this code.

$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));
  • Thanks , good answer for the filtering , but you do need to set the current store first ( as above ) . thank you for your time. – Martin Thompson Apr 14 '18 at 7:47

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.