Skip to content

Commit

Permalink
Fixing resolvers.
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredsgenkins committed May 24, 2019
1 parent 7efb4e0 commit c0b443c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/Model/Resolver/AttributesWithValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Swatches\Helper\Data;

use Magento\Catalog\Model\ProductRepository;

class AttributesWithValue implements ResolverInterface
{
/**
* @var Data
*/
private $swatchHelper;

private $productRepository;

/**
* CustomAttributes constructor.
* @param Data $swatchHelper
*/
public function __construct(
Data $swatchHelper
Data $swatchHelper,
ProductRepository $productRepository
) {
$this->swatchHelper = $swatchHelper;
$this->productRepository = $productRepository;
}

/**
Expand All @@ -54,7 +60,8 @@ public function resolve(
array $value = null,
array $args = null
) {
$product = isset($value['product']) ? $value['product']['model'] : $value['model'];
$product = $this->productRepository->getById($value['entity_id']);
// $product = isset($value['product']) ? $value['product']['model'] : $value['model'];
$attributes = $product->getAttributes();
$attributesToSelect = array_unique($args['attributes']);
$attributesToReturn = [];
Expand Down
2 changes: 1 addition & 1 deletion src/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type AttributeWithValue {
attribute_type: String
attribute_value: String
attribute_label: String
attribute_id: String
attribute_id: Int
attribute_options: [AttributeWithValueOption]
}

Expand Down

0 comments on commit c0b443c

Please sign in to comment.