Skip to content

Commit 65a094b

Browse files
committed
ACP2E-3945: Customer Order GraphQL : Retrieve product categories for the associated product is "not visible individually
1 parent b5bd09b commit 65a094b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Categories.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CatalogGraphQl\Model\Resolver;
99

1010
use Magento\Catalog\Api\Data\CategoryInterface;
11+
use Magento\Catalog\Model\Product\Visibility;
1112
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
1213
use Magento\CatalogGraphQl\Model\AttributesJoiner;
1314
use Magento\CatalogGraphQl\Model\Category\Hydrator as CategoryHydrator;
@@ -99,8 +100,12 @@ public function resolve(Field $field, $context, ResolveInfo $info, ?array $value
99100
}
100101
/** @var \Magento\Catalog\Model\Product $product */
101102
$product = $value['model'];
102-
$storeId = $this->storeManager->getStore()->getId();
103-
$categoryIds = $this->productCategories->getCategoryIdsByProduct((int)$product->getId(), (int)$storeId);
103+
if ($product->getVisibility() == Visibility::VISIBILITY_NOT_VISIBLE && in_array('orders', $info->path)) {
104+
$categoryIds = $product->getCategoryIds();
105+
} else {
106+
$storeId = $this->storeManager->getStore()->getId();
107+
$categoryIds = $this->productCategories->getCategoryIdsByProduct((int)$product->getId(), (int)$storeId);
108+
}
104109
$collection = $this->collectionFactory->create();
105110
return $this->valueFactory->create(
106111
function () use ($categoryIds, $info, $collection) {

0 commit comments

Comments
 (0)