Skip to content

Magento\Catalog\Api\ProductRenderListInterface returns products regardless of visibility #20409

@Floddy

Description

@Floddy

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.

Metadata

Metadata

Labels

Component: CatalogInventoryFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: PR CreatedIndicates that Pull Request has been created to fix issueReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions