cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Configurable product does not have sub-products

Magento 2 Configurable product does not have sub-products

I am facing one problem with the configurable product. I am using magento 2.1.1 and when i open category page than it throws me below error.

 

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Configurable product "red-wine-liqueur-vinegar" does not have sub-products

Exception #0 (Magento\Framework\Exception\LocalizedException): Configurable product "red-wine-liqueur-vinegar" does not have sub-products
#0 D:\xampp\htdocs\m2migration\demo\vendor\magento\module-configurable-product\Pricing\Price\ConfigurableRegularPrice.php(71): Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver->resolvePrice(Object(Magento\Catalog\Model\Product\Interceptor)

When i am edit this configurable product from admin than it shows "Requested product doesn't exist".

Let me know if by using any query or programmatically we can resolve the issue.

Thanks for your answer in advance.

 

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.
4 REPLIES 4

Re: Magento 2 Configurable product does not have sub-products

This is due to the configurable product doesn't have their associate product.

Yes,  programmatically you can do it. You need the ids of parent product(configurable) and associate product(child) . Here I am attaching sample code.

   

        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
        $product = $productCollection->load(Configurable_product_id);
        try{
                $childIds[] = ''; //Ids of child product (array)
                $product->setAssociatedProductIds($childIds);
                $product->save();

        }catch (\Exception $e){
               return false;
        }
 

 

Re: Magento 2 Configurable product does not have sub-products

Hello Manish, Thanks for your answer but its not working. It throwing and error.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Magento 2 Configurable product does not have sub-products

Please, can you paste your error here in detail so we will try to best solution? Actually above is running code.

Re: Magento 2 Configurable product does not have sub-products

Hello @ipragmatech,

I have already subscribed the error in my above message.

Actually when i will try to open Configurable Product in admin than its Showing Message like "Requested product doesn't exist [] []" and when i will try to access category page than its printing message in system.log file like

Configurable product "red-wine-liqueur-vinegar" does not have sub-products

 

Let me know if you can help.

 

Thanks in advance.

 

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.