From cd220884b6e8a4103494262c239b83d23b3a4d97 Mon Sep 17 00:00:00 2001 From: Elena Marchenko Date: Sat, 2 Sep 2017 11:43:24 +0300 Subject: [PATCH 1/5] MAGETWO-69089: [Backport] - Shipping address is sent as the billing address to Braintree - for 2.1 --- .../Braintree/view/frontend/web/template/payment/form.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html b/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html index 888f800581d46..15453c0bf7ccb 100644 --- a/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html +++ b/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html @@ -140,8 +140,11 @@ type="submit" data-bind=" click: placeOrderClick, - attr: {title: $t('Place Order')} - "> + attr: {title: $t('Place Order')}, + css: {disabled: !isPlaceOrderActionAllowed()}, + enable: isActive() + " + disabled> From adac10bbc5052f8f3c341833a9ac7e8d9cc83904 Mon Sep 17 00:00:00 2001 From: Olga Nakonechna Date: Mon, 5 Sep 2016 17:47:25 +0300 Subject: [PATCH 2/5] MAGETWO-69080: [Backport] - [Magento Cloud] - After updating quantity of item in basket, original item quantity is being held in the quantity field on the update item page - for 2.1 --- .../Checkout/CustomerData/DefaultItem.php | 1 + .../layout/checkout_cart_configure.xml | 3 + .../cart/item/configure/updatecart.phtml | 2 +- .../view/configure/product-customer-data.js | 59 +++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js diff --git a/app/code/Magento/Checkout/CustomerData/DefaultItem.php b/app/code/Magento/Checkout/CustomerData/DefaultItem.php index 750581bdfcc00..fe3fe250c21ae 100644 --- a/app/code/Magento/Checkout/CustomerData/DefaultItem.php +++ b/app/code/Magento/Checkout/CustomerData/DefaultItem.php @@ -70,6 +70,7 @@ protected function doGetItemData() 'item_id' => $this->item->getId(), 'configure_url' => $this->getConfigureUrl(), 'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(), + 'product_id' => $this->item->getProduct()->getId(), 'product_name' => $this->item->getProduct()->getName(), 'product_sku' => $this->item->getProduct()->getSku(), 'product_url' => $this->getProductUrl(), diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_configure.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_configure.xml index 14b7329218d55..57b32c26a7619 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_configure.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_configure.xml @@ -6,6 +6,9 @@ */ --> + + + diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml index cdf6efde5deea..2c723f34d49a3 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml @@ -17,7 +17,7 @@
- +
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js new file mode 100644 index 0000000000000..a612b5e2dc6b7 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js @@ -0,0 +1,59 @@ +require([ + 'jquery', + 'Magento_Customer/js/customer-data' +], function ($, customerData) { + 'use strict'; + + var selectors = { + qtySelector: '#product_addtocart_form [name="qty"]', + productIdSelector: '#product_addtocart_form [name="product"]' + }, + cartData = customerData.get('cart'), + productId = $(selectors.productIdSelector).val(), + productQty, + productQtyInput, + + /** + * Updates product's qty input value according to actual data + */ + updateQty = function () { + + if (productQty || productQty === 0) { + productQtyInput = productQtyInput || $(selectors.qtySelector); + + if (productQtyInput && productQty.toString() !== productQtyInput.val()) { + productQtyInput.val(productQty); + } + } + }, + + /** + * Sets productQty according to cart data from customer-data + * + * @param {Object} data - cart data from customer-data + */ + setProductQty = function (data) { + var product; + + if (!(data && data.items && data.items.length && productId)) { + return; + } + product = data.items.find(function (item) { + return item['product_id'] === productId || + item['item_id'] === productId; + }); + + if (!product) { + return; + } + productQty = product.qty; + }; + + cartData.subscribe(function (updateCartData) { + setProductQty(updateCartData); + updateQty(); + }); + + setProductQty(cartData()); + updateQty(); +}); From c680f1ca0965b475ee3146fc75ea231e020bf0cf Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Thu, 14 Sep 2017 14:50:18 +0300 Subject: [PATCH 3/5] MAGETWO-71821: [Github] Paypal Express fails for virtual products #10615 - Backport --- .../Magento/Paypal/Model/Express/Checkout.php | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index a35a5eea96a6b..423b280e86969 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -12,8 +12,6 @@ use Magento\Quote\Model\Quote\Address; use Magento\Framework\DataObject; use Magento\Paypal\Model\Cart as PaypalCart; -use Magento\Framework\App\ObjectManager; -use Magento\Sales\Api\OrderRepositoryInterface; /** * Wrapper that performs Paypal Express and Checkout communication @@ -270,13 +268,6 @@ class Checkout */ protected $totalsCollector; - /** - * Order repository interface. - * - * @var OrderRepositoryInterface - */ - private $orderRepository; - /** * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Customer\Model\Url $customerUrl @@ -805,8 +796,7 @@ public function place($token, $shippingMethodCode = null) $this->ignoreAddressValidation(); $this->_quote->collectTotals(); - $orderId = $this->quoteManagement->placeOrder($this->_quote->getId()); - $order = $this->getOrderRepository()->get($orderId); + $order = $this->quoteManagement->submit($this->_quote); if (!$order) { return; @@ -1174,21 +1164,4 @@ protected function prepareGuestQuote() ->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID); return $this; } - - /** - * Returns order repository instance. - * - * @return OrderRepositoryInterface - * - * @deprecated - */ - private function getOrderRepository() - { - if ($this->orderRepository === null) { - $this->orderRepository = ObjectManager::getInstance() - ->get(OrderRepositoryInterface::class); - } - - return $this->orderRepository; - } } From aea969ed78ae2eab0403f8b3f3041661415e5948 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Mon, 18 Sep 2017 09:48:05 +0300 Subject: [PATCH 4/5] MAGETWO-75222: [2.1] Unexpected prices missing --- .../Cron/DeleteOutdatedPriceValues.php | 51 +++++++++++++------ .../Cron/DeleteOutdatedPriceValuesTest.php | 23 +++++++-- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php b/app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php index de7b692b7297d..70e45984e3a67 100644 --- a/app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php +++ b/app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php @@ -13,7 +13,7 @@ /** * Cron operation is responsible for deleting all product prices on WEBSITE level - * in case 'Catalog Price Scope' configuratoin parameter is set to GLOBAL. + * in case 'Catalog Price Scope' configuration parameter is set to GLOBAL. */ class DeleteOutdatedPriceValues { @@ -48,27 +48,46 @@ public function __construct( } /** - * Delete all price values for non-admin stores if PRICE_SCOPE is global + * Delete all price values for non-admin stores if PRICE_SCOPE is set to global. * * @return void */ public function execute() { - $priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE); - if ($priceScope == Store::PRICE_SCOPE_GLOBAL) { - /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */ - $priceAttribute = $this->attributeRepository - ->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE); - $connection = $this->resource->getConnection(); - $conditions = [ - $connection->quoteInto('attribute_id = ?', $priceAttribute->getId()), - $connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID), - ]; + if ($this->isPriceScopeSetToGlobal() === false) { + return; + } + + /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */ + $priceAttribute = $this->attributeRepository + ->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE); + $connection = $this->resource->getConnection(); + $conditions = [ + $connection->quoteInto('attribute_id = ?', $priceAttribute->getId()), + $connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID), + ]; - $connection->delete( - $priceAttribute->getBackend()->getTable(), - $conditions - ); + $connection->delete( + $priceAttribute->getBackend()->getTable(), + $conditions + ); + } + + /** + * Checks if price scope config option explicitly equal to global value. + * + * Such strict comparision is required to prevent price deleting when + * price scope config option is null for some reason. + * + * @return bool + */ + private function isPriceScopeSetToGlobal() + { + $priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE); + if ($priceScope === null) { + return false; } + + return (int)$priceScope === Store::PRICE_SCOPE_GLOBAL; } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Cron/DeleteOutdatedPriceValuesTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Cron/DeleteOutdatedPriceValuesTest.php index ae714ea85f81a..ffe72a68e0276 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Cron/DeleteOutdatedPriceValuesTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Cron/DeleteOutdatedPriceValuesTest.php @@ -42,11 +42,13 @@ public function setUp() /** * @magentoDataFixture Magento/Catalog/_files/product_simple.php * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php - * @magentoConfigFixture current_store catalog/price/scope 2 + * @magentoConfigFixture current_store catalog/price/scope 1 * @magentoDbIsolation enabled */ public function testExecute() { + $defaultStorePrice = 10.00; + $secondStorePrice = 9.99; $secondStoreId = $this->store->load('fixture_second_store')->getId(); /** @var \Magento\Catalog\Model\Product\Action $productAction */ $productAction = $this->objectManager->create( @@ -64,7 +66,7 @@ public function testExecute() ); $product->setOrigData(); $product->setStoreId($secondStoreId); - $product->setPrice(9.99); + $product->setPrice($secondStorePrice); $productResource->save($product); $attribute = $this->objectManager->get(\Magento\Eav\Model\Config::class) @@ -73,22 +75,33 @@ public function testExecute() 'price' ); $this->assertEquals( - '9.99', + $secondStorePrice, $productResource->getAttributeRawValue($productId, $attribute->getId(), $secondStoreId) ); /** @var MutableScopeConfigInterface $config */ $config = $this->objectManager->get( MutableScopeConfigInterface::class ); + + $config->setValue( + \Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE, + null, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT + ); + $this->cron->execute(); + $this->assertEquals( + $secondStorePrice, + $productResource->getAttributeRawValue($productId, $attribute->getId(), $secondStoreId) + ); + $config->setValue( \Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE, \Magento\Store\Model\Store::PRICE_SCOPE_GLOBAL, ScopeConfigInterface::SCOPE_TYPE_DEFAULT ); - /** @var \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ $this->cron->execute(); $this->assertEquals( - '10.0000', + $defaultStorePrice, $productResource->getAttributeRawValue($productId, $attribute->getId(), $secondStoreId) ); } From 4f2410601cf850f110bd6ff8b0ff221a8f7cb7cc Mon Sep 17 00:00:00 2001 From: Iurii Ivashchenko Date: Mon, 25 Sep 2017 12:19:42 +0300 Subject: [PATCH 5/5] MAGETWO-69080: [Backport] - [Magento Cloud] - After updating quantity of item in basket, original item quantity is being held in the quantity field on the update item page - for 2.1 --- .../templates/cart/item/configure/updatecart.phtml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml index 2c723f34d49a3..dee14a2e25950 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml @@ -15,18 +15,20 @@
shouldRenderQuantity()): ?>
- +
- +
getChildHtml('', true) ?>