cancel
Showing results for 
Search instead for 
Did you mean: 

Magento Catalog Permissions Module Bug: Product set to Hidden

Magento Catalog Permissions Module Bug: Product set to Hidden

Hello,

 

From last few days, we faced one issue of product is not accessible from the website front-end and redirecting to the home page.

Below is the error log in the exception.log file.

 

report.CRITICAL: You may need more permissions to access this product. {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): You may need more permissions to access this product. at /app/fgvmfeeirpu5w/vendor/magento/module-catalog-permissions/Observer/ApplyProductPermissionObserver.php:94)"} []

 

We debug the code and found that the below code is responsible for that. and it hides the product for the login customer group.

 

 

//file location: \Magento\CatalogPermissions\Observer\ApplyPermissionsOnProduct.php
public function execute($product) { if ($product->getData('grant_catalog_category_view') == -2 || $product->getData('grant_catalog_category_view') != -1 && !$this->_catalogPermData->isAllowedCategoryView() ) { $product->setIsHidden(true); } ...... }

 

 

Below are steps to reproduce this issue,
$product->getData('grant_catalog_category_view') value should be -2 and

$this->_catalogPermData->isAllowedCategoryView() value should 1 and then you will face this issue.

 

I think this is due to wrong OR AND added to the if statement.

I think OR condition should be wrapped in ( ) as below.

 

 

public function execute($product)
{
        if (($product->getData('grant_catalog_category_view') == -2
            || $product->getData('grant_catalog_category_view') != -1)
            && !$this->_catalogPermData->isAllowedCategoryView()
        ) {
            $product->setIsHidden(true);
        }
        ......
}

 

 

If we update the if condition as above, then I think that issue will be fixed but i wanted to know others' thoughts and the Core Adobe team's thoughts on the same and if this is a core Magento issue, then the core team can fix it for everyone.

 

 

Magento Version: Commerce Cloud 2.4.3 (Same issue in 2.4.5)

NOTE: We are using Magento Shared Catalog in our website.

Thanks,
Vish