stockStatusRepository = $stockStatusRepository; } /** * @inheritdoc */ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) { if (!array_key_exists('model', $value) || !$value['model'] instanceof ProductInterface) { throw new LocalizedException(__('"model" value should be specified')); } /* @var $product ProductInterface */ $product = $value['model']; $stockStatus = $this->stockStatusRepository->get($product->getId()); $productStockStatus = (int)$stockStatus->getStockStatus(); return $productStockStatus === StockStatusInterface::STATUS_IN_STOCK ? 'IN_STOCK' : 'OUT_OF_STOCK'; } }