Skip to content

Commit 0baf604

Browse files
committed
PWA-1654: Staged upcoming products don't show up in categoryList query for preview
- modify interface
1 parent 8bce230 commit 0baf604

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

app/code/Magento/CatalogUrlRewriteGraphQl/Model/DataProvider/UrlRewrite/CatalogTreeDataProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,18 @@ public function __construct(
5252
* @param string $entity_type
5353
* @param int $id
5454
* @param ResolveInfo|null $info
55+
* @param int|null $storeId
5556
* @return array
5657
* @throws GraphQlNoSuchEntityException
5758
*/
5859
public function getData(
5960
string $entity_type,
6061
int $id,
61-
ResolveInfo $info = null
62+
ResolveInfo $info = null,
63+
int $storeId = null
6264
): array {
6365
$categoryId = (int)$id;
64-
$categoriesTree = $this->categoryTree->getTree($info, $categoryId);
66+
$categoriesTree = $this->categoryTree->getTree($info, $categoryId, $storeId);
6567
if (empty($categoriesTree) || ($categoriesTree->count() == 0)) {
6668
throw new GraphQlNoSuchEntityException(__('Category doesn\'t exist'));
6769
}

app/code/Magento/CatalogUrlRewriteGraphQl/Model/DataProvider/UrlRewrite/ProductDataProvider.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite;
99

1010
use Magento\Catalog\Model\ProductRepository;
11+
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1213
use Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderInterface;
1314

@@ -28,17 +29,23 @@ public function __construct(
2829
}
2930

3031
/**
31-
* Get product data
32+
* Get catalog tree data
3233
*
3334
* @param string $entity_type
3435
* @param int $id
3536
* @param ResolveInfo|null $info
37+
* @param int|null $storeId
3638
* @return array
37-
* @throws \Magento\Framework\Exception\NoSuchEntityException
39+
* @throws NoSuchEntityException
40+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3841
*/
39-
public function getData(string $entity_type, int $id, ResolveInfo $info = null): array
40-
{
41-
$product = $this->productRepository->getById($id);
42+
public function getData(
43+
string $entity_type,
44+
int $id,
45+
ResolveInfo $info = null,
46+
int $storeId = null
47+
): array {
48+
$product = $this->productRepository->getById($id, false, $storeId);
4249
$result = $product->getData();
4350
$result['model'] = $product;
4451
return $result;

app/code/Magento/CmsUrlRewriteGraphQl/Model/DataProvider/UrlRewrite/Page.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ public function __construct(
3535
* @param string $entity_type
3636
* @param int $id
3737
* @param ResolveInfo|null $info
38+
* @param int|null $storeId
3839
* @return array
3940
* @throws NoSuchEntityException
41+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4042
*/
41-
public function getData(string $entity_type, int $id, ResolveInfo $info = null): array
42-
{
43+
public function getData(
44+
string $entity_type,
45+
int $id,
46+
ResolveInfo $info = null,
47+
int $storeId = null
48+
): array {
4349
$result = $this->pageDataProvider->getDataByPageId((int)$id);
4450
$result['type_id'] = $entity_type;
4551
return $result;

app/code/Magento/UrlRewriteGraphQl/Model/DataProvider/EntityDataProviderComposite.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ public function __construct(array $dataProviders = [])
3333
* @param string $entity_type
3434
* @param int $id
3535
* @param ResolveInfo|null $info
36+
* @param int|null $storeId
3637
* @return array
3738
*/
38-
public function getData(string $entity_type, int $id, ResolveInfo $info = null): array
39-
{
39+
public function getData(
40+
string $entity_type,
41+
int $id,
42+
ResolveInfo $info = null,
43+
int $storeId = null
44+
): array {
4045
return $this->dataProviders[strtolower($entity_type)]->getData(
4146
$entity_type,
4247
$id,
43-
$info
48+
$info,
49+
$storeId
4450
);
4551
}
4652
}

app/code/Magento/UrlRewriteGraphQl/Model/DataProvider/EntityDataProviderInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ interface EntityDataProviderInterface
1717
* @param string $entity_type
1818
* @param int $id
1919
* @param ResolveInfo|null $info
20+
* @param int|null $storeId
2021
* @return array
2122
*/
2223
public function getData(
2324
string $entity_type,
2425
int $id,
25-
ResolveInfo $info = null
26+
ResolveInfo $info = null,
27+
int $storeId = null
2628
): array;
2729
}

app/code/Magento/UrlRewriteGraphQl/Model/Resolver/Route.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ public function resolve(
5656
$value,
5757
$args
5858
);
59-
59+
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
6060
if ($resultArray) {
61-
$result = $this->entityDataProviderComposite->getData($resultArray['type'], (int)$resultArray['id'], $info);
61+
$result = $this->entityDataProviderComposite->getData(
62+
$resultArray['type'],
63+
(int)$resultArray['id'],
64+
$info,
65+
$storeId
66+
);
6267
$result['redirect_code'] = $resultArray['redirect_code'];
6368
$result['relative_url'] = $resultArray['relative_url'];
6469
$result['type'] = $resultArray['type'];

0 commit comments

Comments
 (0)