From 5e7e1daa5581a08623b1c4bafd9e41e15165d501 Mon Sep 17 00:00:00 2001 From: eugene-shab Date: Fri, 26 Oct 2018 14:10:39 +0300 Subject: [PATCH 001/109] addConfigurableProductsToCart --- .../AddConfigurableProductsToCart.php | 89 +++++++++++++++++++ .../etc/schema.graphqls | 35 ++++++++ 2 files changed, 124 insertions(+) create mode 100644 app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/AddConfigurableProductsToCart.php diff --git a/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/AddConfigurableProductsToCart.php b/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/AddConfigurableProductsToCart.php new file mode 100644 index 000000000000..5b908835adbe --- /dev/null +++ b/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/AddConfigurableProductsToCart.php @@ -0,0 +1,89 @@ +arrayManager = $arrayManager; + $this->getCartForUser = $getCartForUser; + $this->addProductsToCart = $addProductsToCart; + $this->extractDataFromCart = $extractDataFromCart; + } + + /** + * @inheritdoc + */ + public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) + { + $cartHash = $this->arrayManager->get('input/cart_id', $args); + $cartItems = $this->arrayManager->get('input/cartItems', $args); + + if (!isset($cartHash)) { + throw new GraphQlInputException(__('Missing key "cart_id" in cart data')); + } + + if (!isset($cartItems) || !is_array($cartItems) || empty($cartItems)) { + throw new GraphQlInputException(__('Missing key "cartItems" in cart data')); + } + + $currentUserId = $context->getUserId(); + $cart = $this->getCartForUser->execute((string)$cartHash, $currentUserId); + + $this->addProductsToCart->execute($cart, $cartItems); + $cartData = $this->extractDataFromCart->execute($cart); + + return [ + 'cart' => $cartData, + ]; + } +} diff --git a/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls b/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls index 267a94a1d434..44ba8e7a957f 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls +++ b/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls @@ -1,5 +1,8 @@ # Copyright © Magento, Inc. All rights reserved. # See COPYING.txt for license details. +type Mutation { + addConfigurableProductsToCart(input: AddConfigurableProductsToCartInput): AddConfigurableProductsToCartOutput @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\AddConfigurableProductsToCart") +} type ConfigurableProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "ConfigurableProduct defines basic features of a configurable product and its simple product variants") { variants: [ConfigurableVariant] @doc(description: "An array of variants of products") @resolver(class: "Magento\\ConfigurableProductGraphQl\\Model\\Resolver\\ConfigurableVariant") @@ -35,3 +38,35 @@ type ConfigurableProductOptionsValues @doc(description: "ConfigurableProductOpti store_label: String @doc(description: "The label of the product on the current store") use_default_value: Boolean @doc(description: "Indicates whether to use the default_label") } + +input AddConfigurableProductsToCartInput { + cart_id: String! + cartItems: [ConfigurableProductCartItemInput!]! +} + +type AddConfigurableProductsToCartOutput { + cart: Cart! +} + +input ConfigurableProductCartItemInput { + data: CartItemDetailsInput! + variant_sku: String! + customizable_options:[CustomizableOptionInput!] +} + +type ConfigurableCartItem implements CartItemInterface { + customizable_options: [SelectedCustomizableOption]! + configurable_options: [SelectedConfigurableOption!]! +} + +type SelectedConfigurableOption { + id: Int! + option_label: String! + value_id: Int! + value_label: String! +} + +input CartItemDetailsInput { + sku: String! + qty: Float! +} From d5bece530c0b76c8a8bd97e1b0031b2c082a6fe5 Mon Sep 17 00:00:00 2001 From: eugene-shab Date: Fri, 26 Oct 2018 15:01:13 +0300 Subject: [PATCH 002/109] Updated PHPDoc Comments --- app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php | 2 ++ .../Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php | 1 + 2 files changed, 3 insertions(+) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php index 96259f226494..005cf3a10ca8 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php @@ -45,6 +45,8 @@ public function __construct( * @param Quote $cart * @param array $cartItems * @throws GraphQlInputException + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException */ public function execute(Quote $cart, array $cartItems): void { diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php index aa5b41daebdc..2303d2aa14f0 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php @@ -61,6 +61,7 @@ public function __construct( * @return void * @throws GraphQlNoSuchEntityException * @throws GraphQlInputException + * @throws \Magento\Framework\Exception\LocalizedException */ public function execute(Quote $cart, array $cartItemData): void { From 109a44b7565641e42522c1fb1a77510a5d4b8ad9 Mon Sep 17 00:00:00 2001 From: eugene-shab Date: Fri, 26 Oct 2018 15:07:27 +0300 Subject: [PATCH 003/109] Move CartItemDetailsInput to quote scheme. --- .../Magento/ConfigurableProductGraphQl/etc/schema.graphqls | 5 ----- app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls b/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls index 44ba8e7a957f..12841a6e4510 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls +++ b/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls @@ -65,8 +65,3 @@ type SelectedConfigurableOption { value_id: Int! value_label: String! } - -input CartItemDetailsInput { - sku: String! - qty: Float! -} diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls index f692aa57b218..763f4031c7c3 100644 --- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls +++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls @@ -94,3 +94,8 @@ type CartItemSelectedOptionValuePrice { units: String! type: PriceTypeEnum! } + +input CartItemDetailsInput { + sku: String! + qty: Float! +} From 583ac3683361b823757d2ce1221825bff4a8aa61 Mon Sep 17 00:00:00 2001 From: eugene-shab Date: Mon, 29 Oct 2018 14:39:45 +0200 Subject: [PATCH 004/109] Fix hard depends. --- app/code/Magento/ConfigurableProductGraphQl/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/ConfigurableProductGraphQl/composer.json b/app/code/Magento/ConfigurableProductGraphQl/composer.json index a22df27734b7..0f0bd5d70a4c 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/composer.json +++ b/app/code/Magento/ConfigurableProductGraphQl/composer.json @@ -7,6 +7,7 @@ "magento/module-catalog": "*", "magento/module-configurable-product": "*", "magento/module-catalog-graph-ql": "*", + "magento/module-quote-graph-ql": "*", "magento/framework": "*" }, "license": [ From c0df2e42bdd4d30c1db58d62bfba2b2781531c27 Mon Sep 17 00:00:00 2001 From: Denis Papec Date: Wed, 31 Oct 2018 21:30:42 +0000 Subject: [PATCH 005/109] Fix for currency update in crontab area --- app/code/Magento/Directory/Model/CurrencyConfig.php | 2 +- .../Directory/Test/Unit/Model/CurrencyConfigTest.php | 5 +++-- .../Magento/Directory/Model/CurrencyConfigTest.php | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Directory/Model/CurrencyConfig.php b/app/code/Magento/Directory/Model/CurrencyConfig.php index fdb561c22417..f7230df6e86e 100644 --- a/app/code/Magento/Directory/Model/CurrencyConfig.php +++ b/app/code/Magento/Directory/Model/CurrencyConfig.php @@ -57,7 +57,7 @@ public function __construct( */ public function getConfigCurrencies(string $path) { - $result = $this->appState->getAreaCode() === Area::AREA_ADMINHTML + $result = in_array($this->appState->getAreaCode(), [Area::AREA_ADMINHTML, Area::AREA_CRONTAB]) ? $this->getConfigForAllStores($path) : $this->getConfigForCurrentStore($path); sort($result); diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyConfigTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyConfigTest.php index 9b52bae26f90..e594be90b26d 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyConfigTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyConfigTest.php @@ -68,7 +68,7 @@ protected function setUp() } /** - * Test get currency config for admin and storefront areas. + * Test get currency config for admin, crontab and storefront areas. * * @dataProvider getConfigCurrenciesDataProvider * @return void @@ -91,7 +91,7 @@ public function testGetConfigCurrencies(string $areCode) ->method('getCode') ->willReturn('testCode'); - if ($areCode === Area::AREA_ADMINHTML) { + if (in_array($areCode, [Area::AREA_ADMINHTML, Area::AREA_CRONTAB])) { $this->storeManager->expects(self::once()) ->method('getStores') ->willReturn([$store]); @@ -121,6 +121,7 @@ public function getConfigCurrenciesDataProvider() { return [ ['areaCode' => Area::AREA_ADMINHTML], + ['areaCode' => Area::AREA_CRONTAB], ['areaCode' => Area::AREA_FRONTEND], ]; } diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencyConfigTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencyConfigTest.php index b620d9097b4b..10f2749ddace 100644 --- a/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencyConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencyConfigTest.php @@ -56,7 +56,7 @@ protected function setUp() } /** - * Test get currency config for admin and storefront areas. + * Test get currency config for admin, crontab and storefront areas. * * @dataProvider getConfigCurrenciesDataProvider * @magentoDataFixture Magento/Store/_files/store.php @@ -77,7 +77,7 @@ public function testGetConfigCurrencies(string $areaCode, array $expected) $storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); $storeManager->setCurrentStore($store->getId()); - if ($areaCode === Area::AREA_ADMINHTML) { + if (in_array($areaCode, [Area::AREA_ADMINHTML, Area::AREA_CRONTAB])) { self::assertEquals($expected['allowed'], $this->currency->getConfigAllowCurrencies()); self::assertEquals($expected['base'], $this->currency->getConfigBaseCurrencies()); self::assertEquals($expected['default'], $this->currency->getConfigDefaultCurrencies()); @@ -118,6 +118,14 @@ public function getConfigCurrenciesDataProvider() 'default' => ['BDT', 'USD'], ], ], + [ + 'areaCode' => Area::AREA_CRONTAB, + 'expected' => [ + 'allowed' => ['BDT', 'BNS', 'BTD', 'EUR', 'USD'], + 'base' => ['BDT', 'USD'], + 'default' => ['BDT', 'USD'], + ], + ], [ 'areaCode' => Area::AREA_FRONTEND, 'expected' => [ From e6ed16bec356c52697b6c85582554ca7e3263c75 Mon Sep 17 00:00:00 2001 From: Dzmitry Tabusheu Date: Thu, 1 Nov 2018 11:08:00 +0300 Subject: [PATCH 006/109] MAGETWO-95811: Cannot translate specific admin sections with inline translation - Added translate tags to templates --- app/code/Magento/Ui/view/base/web/js/grid/search/search.js | 2 +- .../base/web/templates/grid/controls/bookmarks/bookmarks.html | 2 +- .../view/base/web/templates/grid/controls/bookmarks/view.html | 2 +- .../Magento/Ui/view/base/web/templates/grid/search/search.html | 3 ++- app/code/Magento/Ui/view/base/web/templates/grid/submenu.html | 2 +- .../Ui/view/base/web/templates/grid/tree-massactions.html | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/search/search.js b/app/code/Magento/Ui/view/base/web/js/grid/search/search.js index fa445a2577ad..be825a391cf0 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/search/search.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/search/search.js @@ -18,7 +18,7 @@ define([ return Element.extend({ defaults: { template: 'ui/grid/search/search', - placeholder: $t('Search by keyword'), + placeholder: 'Search by keyword', label: $t('Keyword'), value: '', previews: [], diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html index 3ef64fd4b537..36a3232c3e61 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html @@ -6,7 +6,7 @@ -->
    diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html index b52669e2cd28..521ce9fc806a 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html @@ -30,7 +30,7 @@
- +