I'm getting the below error:

[2022-09-20T20:10:16.753904+00:00] main.CRITICAL: Error: Call to a member function isSaleable() on null in C:\xampp\htdocs\magento2\vendor\magento\module-catalog\view\frontend\templates\product\list\addto\compare.phtml:32

and the line 32 was contain a code:

<?php if ($product->isSaleable() && $block->isRecurringEnable($product)): ?>

also the $product contains:

public function getProduct()
    $product = parent::getProduct();
    if ($product && $product->getTypeInstance()->getStoreFilter($product) === null) {
        $product->getTypeInstance()->setStoreFilter($this->_storeManager->getStore(), $product);
    return $product;
  • Check you get product details on $product I think it becomes null. Sep 21 at 4:27
  • parent::getProduct() return null, if this is sometimes correct then <?php if ($product && $product->isSaleable() && $block->isRecurringEnable($product)): ?> Sep 21 at 17:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.