I have injected.


In my constructor as $configProductModel

// outputs [];

I know this product to be a simple Product and I'm trying to load the configurable Product so I can get the Parent SKU

1 Answer 1


To get configure product id from its the simple product use below code.

namespace Vendor\Frontendsample\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
    protected $configure;
    protected $resultPageFactory;

     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
     * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configure
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,
        \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configure
        $this->configure = $configure;
        $this->resultPageFactory = $resultPageFactory;

    public function execute()
        $productId = 12;//your simple product id of configure product
        $parentIds = $this->configure->getParentIdsByChild($productId);
        $parentId = array_shift($parentIds);

If you getting nothing from above code, then you should check child(simple) product id of parent(configure) product id, may be its wrong or may be something wrong with your configure product in admin side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.