Skip to content

Magento EE 2.1.0 'Configurable product "%1" does not have sub-products' #5762

@etessari

Description

@etessari

Steps to reproduce

  1. Create configurable product with no simple products associated
  2. Associate product to category
  3. Save category

Actual result

  1. Exception: Configurable product "%1" does not have sub-products

The problem is with the method, cause the configurable product has no child:

<?php
namespace Magento\ConfigurableProduct\Pricing\Price;

/**
     * @param \Magento\Framework\Pricing\SaleableInterface|\Magento\Catalog\Model\Product $product
     * @return float
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
    {
        $price = null;
        foreach ($this->configurable->getUsedProducts($product) as $subProduct) {
            $productPrice = $this->priceResolver->resolvePrice($subProduct);
            $price = $price ? min($price, $productPrice) : $productPrice;
        }
        if ($price === null) {
            throw new \Magento\Framework\Exception\LocalizedException(
                __('Configurable product "%1" does not have sub-products', $product->getSku())
            );
        }
        return (float)$price;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions