1

I have made sure in the back end have the option for "Display Out of Stock Products" is set to "Yes".

I have already used the suggestion from this page:

http://www.tripleginteractive.com/blog/magento/magento-configurable-products-simple-product-data/

That worked for me on the category page that lists products (template 'catalog/product/list.phtml'). However, when I use that same code on the product view page (template 'catalog/product/view.phtml') it will not show products that are out of stock.

1

If you show want to out of stock products then try below code

$ConfiguarblEProduct=Mage::getModel("catalog/product")->load($conFigproductId);
 $allProducts = $ConfiguarblEProduct->getProduct()->getTypeInstance(true)
                ->getUsedProducts(null, $ConfiguarblEProduct);
         foreach ($allProducts as $product) {
         $product //child Product
         }

If,you want show others out of stock options then try below

Copy app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php to app/code/local/Mage/Catalog/Block/Product/View/Type/Configurable.php Then goto getAllowProducts() functions here you have find

   foreach ($allProducts as $product) {
                    if ($product->isSaleable() || $skipSaleableCheck) {
                        $products[] = $product;
                    }
                }

to

foreach ($allProducts as $product) {       
                    $products[] = $product;
              }
0

Try following

   $collection  =  Mage::getModel('catalog/product')->getCollection();
   $collection->addAttributeToFilter('type_id','configurable');

    foreach($collection as $product)
    {

    }

For loading configurable and simple as well try

$collection->addAttributeToFilter('type_id', array('in' => array('configurable','simple')));

You also can add the another attribute filter to get the collection like status '1' or '0' or stock status also. hope this code will help you to get the collection.

  • Thanks for your help. I tried this, but I was experiencing the same problem as with the above code. I found the issue with the code, though, and have posted my resolution. – BVBAccelerate Jul 14 '14 at 15:57
0

So, it appears that the code was correct, but adding the products to the proper store was the issue. We've been importing products using the import tool, and apparently it wasn't adding them to the store during import. I'm not sure why this would only affect their display on the product view page, and not the category product listing page. So, I guess the problem wasn't the code, but that somehow this code used on the listing page is not affected by the store the products are assigned to, but this code on the product view page is. This is an odd quirk, so I figured I'd post how I resolved this issue in case anyone runs into the same thing

  1. After you've done an import of products, in the admin area go to 'Catalog' > 'Manage Products'. Click the orange 'Select All' link near the top left, the in the dropdown to the right with the 'Actions' label, choose 'Update Attributes' then click 'Submit'.
  2. Choose the 'Websites' tab on the left hand side.
  3. Click the checkbox under the 'Add Products To Websites' heading next to 'Main Website' and click 'Save'
  4. Go to 'System' > 'Index Management'
  5. Click the 'Reindex Data' link next to the ones that say 'Reindex Required'

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.