Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:08:50+00:00 2026-06-17T05:08:50+00:00

We have made an xml file for our products and we have a problem.

  • 0

We have made an xml file for our products and we have a problem.

In our Magento shop all configurable products stay in stock also if simple products have a qty of 0. We need this function for our administration / stock system. We have a filter set that filters out all products that are not in stock (see below). Now we also need a filter for configurable products that are in stock, but the simple products are out of stock and have a qty of 0.

Filter to not show out of stock products

->joinField('is_in_stock',
                'cataloginventory/stock_item',
                'is_in_stock',
                'product_id=entity_id',
                'is_in_stock=1',
                '{{table}}.stock_id=1',
                'left');

        $products->addAttributeToFilter('is_in_stock', array('eq' => 1));

So example:

Configurable product: is in stock
Simple 1, simple 2, simple 3: are out of stock

We need to filter out the configurable product with all simple products with status out of stock or qty0

It would be great if someone has the answer because we just do not see the solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:08:51+00:00Added an answer on June 17, 2026 at 5:08 am

    Here is a script with which you can find all those configurables that do not have simples with stock. Afterwards you could then use that array of Ids to exclude them in your filter.

    <?php
    require_once('app/Mage.php');
    umask(0);
    Mage::app();
    
    $collectionConfigurable = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('type_id', array('eq' => 'configurable'));
    
    $outOfStockConfis = array();
    foreach ($collectionConfigurable as $_configurableproduct) {
        $product = Mage::getModel('catalog/product')->load($_configurableproduct->getId());
        if (!$product->getData('is_salable')) {
           $outOfStockConfis[] = $product->getId();
        }
    }
    

    Then use this to remove the configurable products which are not saleable from your collection:

    $products->addAttributeToFilter('entity_id',array('nin' => $outOfStockConfis));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that is validating against a schema. However on our
i have made the following animation xml file in my android project: <?xml version=1.0
I have made a SSIS package to create an XML file, which works fine
I have made following relative layout in an xml file lets say add_relative_layout.xml <?xml
I have two dataGridViews that load up an XML file each, I have made
I have made a XML file: <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <item android:state_pressed=true android:drawable=@drawable/calender_h
I have made following changes to the POM.xml file for adding a manifest file
I have made one application which can parse the given xml file independent of
I have made a XML parser that list correctly in the UITableViewController. It passes
I have an XDocument class with the XML contents already made. I basically want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.