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.
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; }
Hello Manish, Thanks for your answer but its not working. It throwing and error.
Please, can you paste your error here in detail so we will try to best solution? Actually above is running code.
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.