I have the next error when a product is added to the cart:

Requested product doesn't exist

This comes from the following method:


 public function getById($productId, $editMode = false, $storeId = null, $forceReload = false)
        $cacheKey = $this->getCacheKey([$editMode, $storeId]);
        if (!isset($this->instancesById[$productId][$cacheKey]) || $forceReload) {
            $product = $this->productFactory->create();
            if ($editMode) {
                $product->setData('_edit_mode', true);
            if ($storeId !== null) {
                $product->setData('store_id', $storeId);
            $this->logger->debug('Repo2' . $productId);
            $product->load($productId); //            $this->logger->debug(var_export(get_class_methods($product), true));
            if ($productId == '') {
                return nulL;
            if (!$product->getId()) {
                throw new NoSuchEntityException(__('Requested product doesn\'t exist'));
            $this->cacheProduct($cacheKey, $product);
        return $this->instancesById[$productId][$cacheKey];

With the logger I see that three calls are made and the third the $productId has no value and skip the exception


enter image description here

I need to know where the third call is made to see the values it sends.


I have found the third call, it is at the time of validating the sales-rule:

This returns a null object:

$product = $model->getProduct();


public function validate(\Magento\Framework\Model\AbstractModel $model)
        //@todo reimplement this method when is fixed MAGETWO-5713
        /** @var \Magento\Catalog\Model\Product $product */

        $product = $model->getProduct();
        $this->logger->debug(var_export(get_class_methods($product), true));
        if (!$product instanceof \Magento\Catalog\Model\Product) {
            $product = $this->productRepository->getById($model->getProductId());

            $model->getPrice() // possible bug: need to use $model->getBasePrice()

        $attrCode = $this->getAttribute();

        if ($attrCode === 'category_ids') {
            return $this->validateAttribute($this->_getAvailableInCategories($product->getId()));

        if ($attrCode === 'quote_item_price') {
            $numericOperations = $this->getDefaultOperatorInputByType()['numeric'];
            if (in_array($this->getOperator(), $numericOperations)) {
                $this->setData('value', $this->getFormattedPrice($this->getValue()));

        return parent::validate($product);

I have the same error but if I comment all the code and return directly true it is possible to add products to the checkout. But it is not a good solution since here it validates the offers.

  • what problems are you getting now after you made edits ? Oct 23, 2018 at 14:16
  • @ShashankKumrawat The same error, I update the main post, thanks!
    – chdzma
    Oct 24, 2018 at 7:17

1 Answer 1


Controller are called when product is add to cart.


And this is the action controller.


The message 'Requested product doesn't exist' is triggered whenever Magento 2 tries to load a product which does not have a SKU.

To check which products do not have a SKU, sort the table catalog_product_entity by SKU. All the products with no SKU will then be grouped together. You can then fix this issue by manually adding the SKUs to the products in this table (though don't make a habit of directly editing the database - that way madness lies).

For more reference check below link

  1. community.magento.com
  2. magento.stackexchange.com

I hope it helps!

  • Thanks for your response, I have checked all the products and they have SKU, I have updated the main post with some more information
    – chdzma
    Oct 23, 2018 at 13:52
  • With your updated code what error you got? is there any similarity between your previous & new edit post? Oct 24, 2018 at 4:41
  • The same error, I update the main post, thanks!
    – chdzma
    Oct 24, 2018 at 7:16

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.