-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Summary (*)
Magento\Catalog\Api\ProductRenderListInterface returns products regardless of visibility.
Reproduced in 2.2.7, but 2.3-develop has the same error in di.xml.
Examples (*)
Hard to give an example, but here's some abuse of object manager ran in the magerun2 dev console.
- Find a product that is not visible invividually. In the snippet below, it's a product from the sample data (24-WG081-gray)
- Run the following code:
//Initiating stuff that needs to be initiated...
\Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Framework\App\State')->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND);
\Magento\Framework\App\ObjectManager::getInstance()->configure(\Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Framework\ObjectManager\ConfigLoaderInterface')->load(\Magento\Framework\App\Area::AREA_FRONTEND));
//Where it actually happens
$sc = \Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Framework\Api\SearchCriteriaBuilder')->addFilter('sku', '24-WG081-gray')->create();
\Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Catalog\Api\ProductRenderListInterface')->getList($sc, 1, 'USD')->getItems();
Expected result
No results on the search
Actual result
One result on the search
Proposed solution
The issue is that in this line:
https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/CatalogInventory/etc/di.xml#L114
the type has a leading backslash, which for some reason has the effect that Magento\Catalog\Model\ProductVisibilityCondition, as defined here:
https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Catalog/etc/di.xml#L1082
is never ran.
Simply removing the leading backslash resolves the issue.