diff --git a/src/Model/Resolver/Category/CanonicalUrl.php b/src/Model/Resolver/Category/CanonicalUrl.php deleted file mode 100755 index c558bd2..0000000 --- a/src/Model/Resolver/Category/CanonicalUrl.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Copyright (c) 2019 Scandiweb, Ltd (https://scandiweb.com) - * @license OSL-3.0 - */ - -declare(strict_types=1); - -namespace ScandiPWA\CatalogGraphQl\Model\Resolver\Category; - -use Magento\Catalog\Model\Category; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; -use Magento\Framework\GraphQl\Config\Element\Field; -use Magento\Framework\GraphQl\Query\ResolverInterface; -use Magento\Framework\UrlInterface; - -/** - * Retrieves category canonical url - */ -class CanonicalUrl implements ResolverInterface -{ - /** - * URL Model instance - * - * @var UrlInterface - */ - protected $_url; - - /** - * CanonicalUrl constructor. - * @param UrlInterface $url - */ - public function __construct( - UrlInterface $url - ) { - $this->_url = $url; - } - - /** - * @inheritdoc - */ - public function resolve( - Field $field, - $context, - ResolveInfo $info, - array $value = null, - array $args = null - ) - { - if (!isset($value['model'])) { - throw new LocalizedException(__('"model" value should be specified')); - } - - /* @var $category Category */ - $category = $value['model']; - return $this->_url->getUrl('category/') . $category->getDataByKey('url_path'); - } -} diff --git a/src/Model/Resolver/Product/CanonicalUrl.php b/src/Model/Resolver/Product/CanonicalUrl.php deleted file mode 100644 index bdb1042..0000000 --- a/src/Model/Resolver/Product/CanonicalUrl.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Copyright (c) 2019 Scandiweb, Ltd (https://scandiweb.com) - * @license OSL-3.0 - */ - -declare(strict_types=1); - -namespace ScandiPWA\CatalogGraphQl\Model\Resolver\Product; - -use Magento\Catalog\Model\Product; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\GraphQl\Config\Element\Field; -use Magento\Framework\GraphQl\Query\ResolverInterface; -use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; -use Magento\Framework\UrlInterface; - -/** - * Resolve data for product canonical URL - */ -class CanonicalUrl implements ResolverInterface -{ - /** - * URL Model instance - * - * @var UrlInterface - */ - protected $_url; - - /** - * CanonicalUrl constructor. - * @param UrlInterface $url - */ - public function __construct( - UrlInterface $url - ) { - $this->_url = $url; - } - - /** - * @inheritdoc - */ - public function resolve( - Field $field, - $context, - ResolveInfo $info, - array $value = null, - array $args = null - ) { - if (!isset($value['model'])) { - throw new LocalizedException(__('"model" value should be specified')); - } - - /* @var $product Product */ - $product = $value['model']; - - return $this->_url->getUrl('product/') . $product->getUrlKey(); - } -} diff --git a/src/etc/di.xml b/src/etc/di.xml index 09b0d6b..9845fe5 100755 --- a/src/etc/di.xml +++ b/src/etc/di.xml @@ -47,9 +47,6 @@ - - diff --git a/src/etc/schema.graphqls b/src/etc/schema.graphqls index 633521c..5fd9792 100755 --- a/src/etc/schema.graphqls +++ b/src/etc/schema.graphqls @@ -52,7 +52,6 @@ interface ProductInterface { interface CategoryInterface { url: String @resolver(class: "ScandiPWA\\CatalogGraphQl\\Model\\Resolver\\Category\\Url") - canonical_url: String @doc(description: "Canonical Url") @resolver(class: "ScandiPWA\\CatalogGraphQl\\Model\\Resolver\\Category\\CanonicalUrl") } type AttributeWithValue {