-
Notifications
You must be signed in to change notification settings - Fork 153
Products: Access to related up sell cross sell product fields #249
Products: Access to related up sell cross sell product fields #249
Conversation
/** | ||
* Attribute to select fields | ||
*/ | ||
public const FIELDS = ['sku', 'name', 'price', 'image', 'url_path', 'url_key']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should take this data from request
@@ -0,0 +1,43 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls, add declare(strict_types=1);
to all of new files
And check code style of all of files
* @throws \Exception | ||
* @return mixed|Value | ||
*/ | ||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use inheritdoc
|
||
$count = 0; | ||
$data = []; | ||
foreach ($collection as $item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach ($data as $key => $value)
|
||
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Related; | ||
|
||
abstract class AbstractDataProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls, don't use supertypes only for code reusing (if a relation is not like type A is subtype of B
)
*/ | ||
protected function prepareCollection($product): void | ||
{ | ||
$this->collection = $product->getCrossSellProductCollection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like proxy on another method
@@ -271,6 +271,9 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\ | |||
websites: [Website] @doc(description: "An array of websites in which the product is available") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Websites") | |||
product_links: [ProductLinksInterface] @doc(description: "An array of ProductLinks objects") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductLinks") | |||
media_gallery_entries: [MediaGalleryEntry] @doc(description: "An array of MediaGalleryEntry objects") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\MediaGalleryEntries") | |||
related_products: RelatedProduct @doc(description: "RelatedProduct") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Related") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like resolver should be Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Related\\RelatedProducts
Why do we need one more layer?
The same for another types of related products
Hello @VoronoyAlexandr, Please let me know if you need any assistance. |
Closing due to inactivity. |
Hi @VoronoyAlexandr, thank you for your contribution! |
Description (*)
PR For issue #198 Products: access to related/up-sell/cross-sell product fields
This PR added functionality for query/response with related products.
Manual testing scenarios (*)
Sample request
Contribution checklist (*)