From 65f263b2bc1d1af62235099007e45da5f1f732f8 Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Tue, 17 May 2016 17:19:38 +0300 Subject: [PATCH 01/32] MAGETWO-52629: Can refresh statistics after deleting product --- .../Magento/Sales/Setup/InstallSchema.php | 33 -------- app/code/Magento/Sales/Setup/Recurring.php | 82 ------------------- .../Magento/Sales/Setup/UpgradeSchema.php | 57 +++++++++++++ app/code/Magento/Sales/etc/module.xml | 2 +- 4 files changed, 58 insertions(+), 116 deletions(-) delete mode 100644 app/code/Magento/Sales/Setup/Recurring.php create mode 100644 app/code/Magento/Sales/Setup/UpgradeSchema.php diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php index 3be723d069f57..0801da31d1171 100644 --- a/app/code/Magento/Sales/Setup/InstallSchema.php +++ b/app/code/Magento/Sales/Setup/InstallSchema.php @@ -5133,17 +5133,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName( - 'sales_bestsellers_aggregated_daily', - 'product_id', - 'catalog_product_entity', - 'entity_id' - ), - 'product_id', - $installer->getTable('catalog_product_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Bestsellers Aggregated Daily' ); @@ -5222,17 +5211,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName( - 'sales_bestsellers_aggregated_monthly', - 'product_id', - 'catalog_product_entity', - 'entity_id' - ), - 'product_id', - $installer->getTable('catalog_product_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Bestsellers Aggregated Monthly' ); @@ -5311,17 +5289,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName( - 'sales_bestsellers_aggregated_yearly', - 'product_id', - 'catalog_product_entity', - 'entity_id' - ), - 'product_id', - $installer->getTable('catalog_product_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Bestsellers Aggregated Yearly' ); diff --git a/app/code/Magento/Sales/Setup/Recurring.php b/app/code/Magento/Sales/Setup/Recurring.php deleted file mode 100644 index 55b7dfb51ba22..0000000000000 --- a/app/code/Magento/Sales/Setup/Recurring.php +++ /dev/null @@ -1,82 +0,0 @@ -metadataPool = $metadataPool; - $this->externalFKSetup = $externalFKSetup; - } - - /** - * {@inheritdoc} - */ - public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) - { - $installer = $setup; - $installer->startSetup(); - - $listTables = [ - 'sales_bestsellers_aggregated_daily' => 'product_id', - 'sales_bestsellers_aggregated_monthly' => 'product_id', - 'sales_bestsellers_aggregated_yearly' => 'product_id', - ]; - foreach ($listTables as $tableName => $columnName) { - $this->addExternalForeignKeys($installer, $tableName, $columnName); - } - - $installer->endSetup(); - } - - /** - * Add external foreign keys - * - * @param SchemaSetupInterface $installer - * @param string $tableName - * @param string $columnName - * @return void - * @throws \Exception - */ - protected function addExternalForeignKeys(SchemaSetupInterface $installer, $tableName, $columnName) - { - $metadata = $this->metadataPool->getMetadata(ProductInterface::class); - $this->externalFKSetup->install( - $installer, - $metadata->getEntityTable(), - $metadata->getIdentifierField(), - $tableName, - $columnName - ); - } -} diff --git a/app/code/Magento/Sales/Setup/UpgradeSchema.php b/app/code/Magento/Sales/Setup/UpgradeSchema.php new file mode 100644 index 0000000000000..fbf2e929a2f0f --- /dev/null +++ b/app/code/Magento/Sales/Setup/UpgradeSchema.php @@ -0,0 +1,57 @@ +startSetup(); + if (version_compare($context->getVersion(), '2.0.2', '<')) { + $connection = $installer->getConnection(); + //sales_bestsellers_aggregated_daily + $connection->dropForeignKey( + $installer->getTable('sales_bestsellers_aggregated_daily'), + $installer->getFkName( + 'sales_bestsellers_aggregated_daily', + 'product_id', + 'catalog_product_entity', + 'entity_id') + ); + //sales_bestsellers_aggregated_monthly + $connection->dropForeignKey( + $installer->getTable('sales_bestsellers_aggregated_monthly'), + $installer->getFkName( + 'sales_bestsellers_aggregated_monthly', + 'product_id', + 'catalog_product_entity', + 'entity_id') + ); + + //sales_bestsellers_aggregated_yearly + $connection->dropForeignKey( + $installer->getTable('sales_bestsellers_aggregated_yearly'), + $installer->getFkName( + 'sales_bestsellers_aggregated_yearly', + 'product_id', + 'catalog_product_entity', + 'entity_id') + ); + + $installer->endSetup(); + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml index 791ddf1108584..19956e8918447 100644 --- a/app/code/Magento/Sales/etc/module.xml +++ b/app/code/Magento/Sales/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + From 286df580dfa699c6a2cb2d9771e5888ee1992235 Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Thu, 19 May 2016 14:44:25 +0300 Subject: [PATCH 02/32] MAGETWO-53030: AssertGiftMessageInFrontendOrderItems has incorrect verification if product has weight --- .../Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php | 2 +- .../Test/Constraint/AssertGiftMessageInFrontendOrderItems.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php index 1f400763c4bb1..4a2bef953a9fd 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php @@ -90,7 +90,7 @@ public function fillGiftMessageItem(GiftMessage $giftMessage, $products = []) /** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */ if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') { foreach ($products as $product) { - if ($product->getProductHasWeight() == 'Yes') { + if ($product->getProductHasWeight() == 'This item has weight') { $this->_rootElement->find( sprintf($this->allowGiftOptions, $product->getName()), Locator::SELECTOR_XPATH diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php index 67d938520452e..1fb1de269a008 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php @@ -62,7 +62,7 @@ public function processAssert( 'message' => $itemGiftMessage->getMessage(), ]; } - if ($product->getProductHasWeight() !== 'Yes') { + if ($product->getProductHasWeight() !== 'This item has weight') { $expectedData = []; } From d6637957a19bde0ad9c3f1866f109f97894aa97e Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 23 May 2016 16:49:51 +0300 Subject: [PATCH 03/32] MAGETWO-53193: Selected address issue on Checkout --- app/code/Magento/Quote/Model/ShippingAddressManagement.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php index 19353fb415b5d..114456fccbc1e 100644 --- a/app/code/Magento/Quote/Model/ShippingAddressManagement.php +++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php @@ -97,6 +97,10 @@ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $addres $quote->setShippingAddress($address); $address = $quote->getShippingAddress(); + if ($customerAddressId === null) { + $address->setCustomerAddressId(null); + } + if ($customerAddressId) { $addressData = $this->addressRepository->getById($customerAddressId); $address = $quote->getShippingAddress()->importCustomerAddressData($addressData); From 98bfb1e0023bb2057654c4791f69f5c7e8412919 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Mon, 23 May 2016 17:10:07 +0300 Subject: [PATCH 04/32] MAGETWO-53217: Error occurred during "save_in_address_book" processing" error during checkout with not saved address --- .../Magento/Checkout/view/frontend/web/js/view/shipping.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index 5ca6c2bd5d87a..481b466dcb1b0 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -183,7 +183,8 @@ define( if (!this.source.get('params.invalid')) { addressData = this.source.get('shippingAddress'); - addressData.save_in_address_book = this.saveInAddressBook; + // if user clicked the checkbox, its value is tue or false. Need to convert. + addressData.save_in_address_book = this.saveInAddressBook ? 1 : 0; // New address must be selected as a shipping address newShippingAddress = createShippingAddress(addressData); From 561e1c5f88ff2f26be6919537012e65814950151 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Mon, 23 May 2016 17:17:33 +0300 Subject: [PATCH 05/32] MAGETWO-53217: Error occurred during "save_in_address_book" processing" error during checkout with not saved address comment fix --- app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index 481b466dcb1b0..c22663c702b25 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -183,7 +183,7 @@ define( if (!this.source.get('params.invalid')) { addressData = this.source.get('shippingAddress'); - // if user clicked the checkbox, its value is tue or false. Need to convert. + // if user clicked the checkbox, its value is true or false. Need to convert. addressData.save_in_address_book = this.saveInAddressBook ? 1 : 0; // New address must be selected as a shipping address From 4740771eb8449b950e1e5e36b32666a1207a8647 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 24 May 2016 12:08:33 +0300 Subject: [PATCH 06/32] MAGETWO-53307: Checkout is broken when purchasing products on persisted session --- .../Persistent/Observer/SetQuotePersistentDataObserver.php | 2 +- .../Test/Unit/Observer/SetQuotePersistentDataObserverTest.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Persistent/Observer/SetQuotePersistentDataObserver.php b/app/code/Magento/Persistent/Observer/SetQuotePersistentDataObserver.php index 58ec7166c3029..1e5314b4b9798 100644 --- a/app/code/Magento/Persistent/Observer/SetQuotePersistentDataObserver.php +++ b/app/code/Magento/Persistent/Observer/SetQuotePersistentDataObserver.php @@ -79,7 +79,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) && $this->quoteManager->isPersistent() ) { //Quote is not actual customer's quote, just persistent - $quote->setIsActive(false)->setIsPersistent(true); + $quote->setIsPersistent(true); } } } diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php index fabdbee91c91c..a5dc4fe208754 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SetQuotePersistentDataObserverTest.php @@ -101,7 +101,6 @@ public function testExecuteWhenSessionIsPersistent() $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(false)); $this->quoteManagerMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true)); - $this->quoteMock->expects($this->once())->method('setIsActive')->with(false)->will($this->returnSelf()); $this->quoteMock->expects($this->once())->method('setIsPersistent')->with(true); $this->model->execute($this->observerMock); } From c67bdfd7615ad2e867ad54801ded68438daa3a53 Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Tue, 24 May 2016 14:59:16 +0300 Subject: [PATCH 07/32] MAGETWO-53362: Gift Message not returned via API on getList #4414 --- .../GiftMessage/Model/Plugin/OrderGetList.php | 27 ++++ .../Unit/Model/Plugin/OrderGetListTest.php | 148 ++++++++++++++++++ app/code/Magento/GiftMessage/etc/di.xml | 1 + 3 files changed, 176 insertions(+) create mode 100644 app/code/Magento/GiftMessage/Model/Plugin/OrderGetList.php create mode 100644 app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderGetListTest.php diff --git a/app/code/Magento/GiftMessage/Model/Plugin/OrderGetList.php b/app/code/Magento/GiftMessage/Model/Plugin/OrderGetList.php new file mode 100644 index 0000000000000..e590d632596da --- /dev/null +++ b/app/code/Magento/GiftMessage/Model/Plugin/OrderGetList.php @@ -0,0 +1,27 @@ +getItems() as $order) { + $this->getOrderGiftMessage($order); + $this->getOrderItemGiftMessage($order); + } + return $resultOrder; + } +} diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderGetListTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderGetListTest.php new file mode 100644 index 0000000000000..677caf45d18ee --- /dev/null +++ b/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderGetListTest.php @@ -0,0 +1,148 @@ +giftMessageOrderRepositoryMock = $this->getMock( + \Magento\GiftMessage\Api\OrderRepositoryInterface::class + ); + $this->giftMessageOrderItemRepositoryMock = $this->getMock( + \Magento\GiftMessage\Api\OrderItemRepositoryInterface::class + ); + $this->orderExtensionFactoryMock = $this->getMock( + \Magento\Sales\Api\Data\OrderExtensionFactory::class, + ['create'], + [], + '', + false + ); + $this->orderItemExtensionFactoryMock = $this->getMock( + \Magento\Sales\Api\Data\OrderItemExtensionFactory::class, + ['create'], + [], + '', + false + ); + $this->orderMock = $this->getMock( + \Magento\Sales\Api\Data\OrderInterface::class + ); + $this->orderExtensionMock = $this->getMock( + \Magento\Sales\Api\Data\OrderExtension::class, + ['getGiftMessage', 'setGiftMessage'], + [], + '', + false + ); + $this->giftMessageMock = $this->getMock( + \Magento\GiftMessage\Api\Data\MessageInterface::class + ); + + $this->orderRepositoryMock = $this->getMock( + \Magento\Sales\Api\OrderRepositoryInterface::class + ); + + $this->collectionMock = $this->getMock( + \Magento\Sales\Model\ResourceModel\Order\Collection::class, + [], + [], + '', + false + ); + $this->plugin = new \Magento\GiftMessage\Model\Plugin\OrderGetList( + $this->giftMessageOrderRepositoryMock, + $this->giftMessageOrderItemRepositoryMock, + $this->orderExtensionFactoryMock, + $this->orderItemExtensionFactoryMock + ); + } + + public function testAfterGetList() + { + //set Gift Message List for Order + $orderId = 1; + $this->orderMock->expects($this->once())->method('getEntityId')->willReturn($orderId); + $this->orderMock + ->expects($this->once()) + ->method('getExtensionAttributes') + ->willReturn($this->orderExtensionMock); + $this->orderExtensionMock->expects($this->once())->method('getGiftMessage')->willReturn([]); + $this->giftMessageOrderRepositoryMock + ->expects($this->once()) + ->method('get') + ->with($orderId) + ->willReturn($this->giftMessageMock); + $this->orderExtensionMock + ->expects($this->once()) + ->method('setGiftMessage') + ->with($this->giftMessageMock) + ->willReturnSelf(); + $this->orderMock + ->expects($this->once()) + ->method('setExtensionAttributes') + ->with($this->orderExtensionMock) + ->willReturnSelf(); + + // set Gift Message on Item Level + $this->orderMock->expects($this->once())->method('getItems')->willReturn([]); + $this->collectionMock->expects($this->once())->method('getItems')->willReturn([$this->orderMock]); + $this->plugin->afterGetList($this->orderRepositoryMock, $this->collectionMock); + } + +} diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml index d660115822d69..4ad49aac0c2da 100644 --- a/app/code/Magento/GiftMessage/etc/di.xml +++ b/app/code/Magento/GiftMessage/etc/di.xml @@ -27,5 +27,6 @@ + From 6fd59216b8a9f2c4abe614509fa1ed1e7d7897af Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Tue, 24 May 2016 16:45:34 +0300 Subject: [PATCH 08/32] MAGETWO-39117: Updating qty that exceeds the qty in stock for registered customer by API should return error fixed item quantity check --- .../Magento/Quote/Model/Quote/Item/CartItemPersister.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php b/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php index 85d3ccb3396ee..aa5879c2840f0 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php +++ b/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php @@ -72,6 +72,12 @@ public function save(CartInterface $quote, CartItemInterface $item) $item = $quote->updateItem($itemId, $buyRequestData); } else { $currentItem->setQty($qty); + if (!empty($currentItem->getErrorInfos())) { + $errors = $currentItem->getErrorInfos(); + /** @var \Magento\Framework\Message\MessageInterface $error */ + $errorData = array_shift($errors); + throw new CouldNotSaveException($errorData['message']); + } } } else { /** add new item to shopping cart */ From edb196cbaf0ac259e1309eabd9563073eb57a7b8 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Tue, 24 May 2016 18:59:05 +0300 Subject: [PATCH 09/32] MAGETWO-53217: Error occurred during "save_in_address_book" processing" error during checkout with not saved address fix for billing address --- .../Checkout/view/frontend/web/js/view/billing-address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index d0b443e50ea8c..b9cf58b51b133 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -159,7 +159,7 @@ define( if (customer.isLoggedIn() && !this.customerHasAddresses) { this.saveInAddressBook(1); } - addressData.save_in_address_book = this.saveInAddressBook(); + addressData.save_in_address_book = this.saveInAddressBook() ? 1 : 0; newBillingAddress = createBillingAddress(addressData); // New address must be selected as a billing address From e200ab1951eb1303050562dc2e9c4018bb56a589 Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Wed, 25 May 2016 11:52:00 +0300 Subject: [PATCH 10/32] MAGETWO-53397: \Magento\Quote\Model\ShippingMethodManagement::estimateByAddressId set not full address details --- .../web/js/model/address-converter.js | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js index 3ee5bd0679827..db00397932aef 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js @@ -117,10 +117,25 @@ define( addressToEstimationAddress: function (address) { var estimatedAddressData = { - country_id: address.countryId, - region: address.region, - region_id: address.regionId, - postcode: address.postcode + 'street': address.street, + 'city': address.city, + 'region_id': address.regionId, + 'region': address.region, + 'country_id': address.countryId, + 'postcode': address.postcode, + 'email': address.email, + 'customer_id': address.customerId, + 'firstname': address.firstname, + 'lastname': address.lastname, + 'middlename': address.middlename, + 'prefix': address.prefix, + 'suffix': address.suffix, + 'vat_id': address.vatId, + 'company': address.company, + 'telephone': address.telephone, + 'fax': address.fax, + 'custom_attributes': address.customAttributes + }; return this.formAddressDataToQuoteAddress(estimatedAddressData); } From 296a5618b5d168a2d3592105ad9141e772bb7385 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Thu, 26 May 2016 10:35:56 +0300 Subject: [PATCH 11/32] MAGETWO-52979: Message about tier price isn't displayed on product required attention block --- .../Test/Repository/CatalogProductSimple.xml | 2 +- .../Catalog/Test/Repository/Product/TierPrice.xml | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index b79d1b61709dd..b216e2d871c71 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -962,7 +962,7 @@ simple-product-%isolation% - default + more_is_cheaper Main Website diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/TierPrice.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/TierPrice.xml index 371ab8eaae6f9..75cf775c5720f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/TierPrice.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/TierPrice.xml @@ -22,6 +22,21 @@ + + + 24 + All Websites [USD] + 3 + ALL GROUPS + + + 15 + All Websites [USD] + 30 + ALL GROUPS + + + 90 From ef12b1707e765a2cd8a16696646d52547d9336f4 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 26 May 2016 11:05:24 +0300 Subject: [PATCH 12/32] MAGETWO-53049: Unexpected login popup after clicking "Go to Checkout" button --- .../frontend/web/js/proceed-to-checkout.js | 2 +- .../Checkout/view/frontend/web/js/sidebar.js | 2 +- .../web/js/model/authentication-popup.js | 5 +++-- .../web/js/view/authentication-popup.js | 21 ++++++++++++------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js b/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js index 1cccaa8613f87..e452547cfa581 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js @@ -18,7 +18,7 @@ define([ event.preventDefault(); - if (!customer().firstname && !cart().isGuestCheckoutAllowed) { + if (!customer().firstname && cart().isGuestCheckoutAllowed === false) { authenticationPopup.showModal(); return false; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js index 6c83cef88472f..c0e7e8fa2cfd3 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -54,7 +54,7 @@ define([ var cart = customerData.get('cart'), customer = customerData.get('customer'); - if (!customer().firstname && !cart().isGuestCheckoutAllowed) { + if (!customer().firstname && cart().isGuestCheckoutAllowed === false) { // set URL for redirect on successful login/registration. It's postprocessed on backend. $.cookie('login_redirect', this.options.url.checkout); if (this.options.url.isRedirectRequired) { diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js b/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js index 0700c5f77960d..b87eac7116991 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js +++ b/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js @@ -11,11 +11,12 @@ define( ], function ($, modal) { 'use strict'; + return { modalWindow: null, /** Create popUp window for provided element */ - createPopUp: function(element) { + createPopUp: function (element) { this.modalWindow = element; var options = { 'type': 'popup', @@ -29,7 +30,7 @@ define( }, /** Show login popup window */ - showModal: function() { + showModal: function () { $(this.modalWindow).modal('openModal'); } } diff --git a/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js b/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js index e6b29ecff26b7..62ed03641b242 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js +++ b/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js @@ -17,8 +17,9 @@ define( 'Magento_Ui/js/modal/alert', 'mage/validation' ], - function($, ko, Component, loginAction, customerData, authenticationPopup, $t, url, alert) { + function ($, ko, Component, loginAction, customerData, authenticationPopup, $t, url, alert) { 'use strict'; + return Component.extend({ registerUrl: window.authenticationPopup.customerRegisterUrl, forgotPasswordUrl: window.authenticationPopup.customerForgotPasswordUrl, @@ -30,11 +31,14 @@ define( template: 'Magento_Customer/authentication-popup' }, - initialize: function() { + /** + * Init + */ + initialize: function () { var self = this; this._super(); url.setBaseUrl(window.authenticationPopup.baseUrl); - loginAction.registerLoginCallback(function() { + loginAction.registerLoginCallback(function () { self.isLoading(false); }); }, @@ -47,13 +51,14 @@ define( }, /** Is login form enabled for current customer */ - isActive: function() { + isActive: function () { var customer = customerData.get('customer'); + return customer() == false; }, /** Show login popup window */ - showModal: function() { + showModal: function () { if (this.modalWindow) { $(this.modalWindow).modal('openModal'); } else { @@ -64,15 +69,15 @@ define( }, /** Provide login action */ - login: function(loginForm) { + login: function (loginForm) { var loginData = {}, formDataArray = $(loginForm).serializeArray(); formDataArray.forEach(function (entry) { loginData[entry.name] = entry.value; }); - if($(loginForm).validation() - && $(loginForm).validation('isValid') + if ($(loginForm).validation() && + $(loginForm).validation('isValid') ) { this.isLoading(true); loginAction(loginData, null, false); From e62f1f39959f6f6d3c93a2357a9331cc4a039d43 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 26 May 2016 12:32:52 +0300 Subject: [PATCH 13/32] MAGETWO-52987: Checkout Zip Validation is not working with specific shipping settings --- .../web/js/model/shipping-rates-validator.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js index 9b82199abbd33..77a071b46c642 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js @@ -29,7 +29,8 @@ define( var checkoutConfig = window.checkoutConfig, validators = [], observedElements = [], - postcodeElement = null; + postcodeElement = null, + postcodeElementName = 'postcode'; return { validateAddressTimeout: 0, @@ -50,7 +51,7 @@ define( * @return {Boolean} */ validateAddressData: function (address) { - return validators.some(function(validator) { + return validators.some(function (validator) { return validator.validate(address); }); }, @@ -64,6 +65,12 @@ define( var self = this, elements = shippingRatesValidationRules.getObservableFields(); + //TODO: Split zip code validation and element binding for shipping rates request + if ($.inArray(postcodeElementName, elements) === -1) { + // Add postcode field to observables if not exist for zip code validation support + elements.push(postcodeElementName); + } + $.each(elements, function (index, field) { uiRegistry.async(formPath + '.' + field)(self.doElementBinding.bind(self)); }); @@ -80,12 +87,12 @@ define( var observableFields = shippingRatesValidationRules.getObservableFields(); if (element && (observableFields.indexOf(element.index) !== -1 || force)) { - if (element.index !== 'postcode') { + if (element.index !== postcodeElementName) { this.bindHandler(element, delay); } } - if (element.index === 'postcode') { + if (element.index === postcodeElementName) { this.bindHandler(element, delay); postcodeElement = element; } From 76a923aed647f07b963f9d29cc3686c1a6f1958e Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Thu, 26 May 2016 17:55:10 +0300 Subject: [PATCH 14/32] MAGETWO-53150: If set custom value to Persistence Lifetime (seconds) persistent isn't applied on frontend --- app/code/Magento/Persistent/Model/Session.php | 11 +++++++++++ .../Observer/SynchronizePersistentInfoObserver.php | 2 +- .../SynchronizePersistentInfoObserverTest.php | 6 ++++-- app/code/Magento/Persistent/etc/frontend/events.xml | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 53da1abcca982..4f81b355b18ba 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -410,4 +410,15 @@ private function getRequest() } return $this->request; } + + /** + * Set `updated_at` to be always changed + * + * @return $this + */ + public function save() + { + $this->setUpdatedAt(gmdate('Y-m-d H:i:s')); + return parent::save(); + } } diff --git a/app/code/Magento/Persistent/Observer/SynchronizePersistentInfoObserver.php b/app/code/Magento/Persistent/Observer/SynchronizePersistentInfoObserver.php index 23123d549b643..34fa20fe79cee 100644 --- a/app/code/Magento/Persistent/Observer/SynchronizePersistentInfoObserver.php +++ b/app/code/Magento/Persistent/Observer/SynchronizePersistentInfoObserver.php @@ -70,7 +70,7 @@ public function execute(Observer $observer) // Quote Id could be changed only by logged in customer if ($this->_customerSession->isLoggedIn() || - $request && $request->getActionName() == 'logout' && $request->getControllerName() == 'account' + $request && $request->getFullActionName() == 'customer_account_logout' ) { $sessionModel->save(); } diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php index 7338cf16c68af..ac64b1740b707 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/SynchronizePersistentInfoObserverTest.php @@ -89,8 +89,10 @@ public function testSynchronizePersistentInfoWhenPersistentDataIsEnabled() ->method('getRequest') ->will($this->returnValue($this->requestMock)); $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); - $this->requestMock->expects($this->once())->method('getActionName')->will($this->returnValue('logout')); - $this->requestMock->expects($this->once())->method('getControllerName')->will($this->returnValue('account')); + $this->requestMock + ->expects($this->once()) + ->method('getFullActionName') + ->will($this->returnValue('customer_account_logout')); $this->sessionMock->expects($this->once())->method('save'); $this->model->execute($this->observerMock); } diff --git a/app/code/Magento/Persistent/etc/frontend/events.xml b/app/code/Magento/Persistent/etc/frontend/events.xml index eb5c92e7d08e2..e40ac5774af11 100644 --- a/app/code/Magento/Persistent/etc/frontend/events.xml +++ b/app/code/Magento/Persistent/etc/frontend/events.xml @@ -29,6 +29,7 @@ + From d5f4517a1a16621ed926ff3f7fefc7e771be13d8 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Fri, 27 May 2016 17:39:47 +0300 Subject: [PATCH 15/32] MAGETWO-39117: Updating qty that exceeds the qty in stock for registered customer by API should return error moved error processing to the quote scope. --- .../Model/Quote/Item/CartItemPersister.php | 6 ----- .../Model/QuoteRepository/SaveHandler.php | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php b/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php index aa5879c2840f0..85d3ccb3396ee 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php +++ b/app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php @@ -72,12 +72,6 @@ public function save(CartInterface $quote, CartItemInterface $item) $item = $quote->updateItem($itemId, $buyRequestData); } else { $currentItem->setQty($qty); - if (!empty($currentItem->getErrorInfos())) { - $errors = $currentItem->getErrorInfos(); - /** @var \Magento\Framework\Message\MessageInterface $error */ - $errorData = array_shift($errors); - throw new CouldNotSaveException($errorData['message']); - } } } else { /** add new item to shopping cart */ diff --git a/app/code/Magento/Quote/Model/QuoteRepository/SaveHandler.php b/app/code/Magento/Quote/Model/QuoteRepository/SaveHandler.php index 1bece9a0887ca..ca218c8d9de1c 100644 --- a/app/code/Magento/Quote/Model/QuoteRepository/SaveHandler.php +++ b/app/code/Magento/Quote/Model/QuoteRepository/SaveHandler.php @@ -7,6 +7,7 @@ use Magento\Quote\Api\Data\CartInterface; use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\CouldNotSaveException; class SaveHandler { @@ -70,6 +71,13 @@ public function save(CartInterface $quote) } } } + $errors = $quote->getErrors(); + if (!empty($errors)) { + $renderedErrors = $this->renderErrors($errors); + throw new CouldNotSaveException( + __('Following errors occurred on save: %1', implode('; ', $renderedErrors)) + ); + } // Billing Address processing $billingAddress = $quote->getBillingAddress(); @@ -83,6 +91,21 @@ public function save(CartInterface $quote) return $quote; } + /** + * @param array $errors + * @return array + */ + private function renderErrors($errors) + { + $renderedErrors = []; + /** @var \Magento\Framework\Message\Error $error */ + foreach ($errors as $error) { + $renderedErrors[] = $error->getText(); + } + return $renderedErrors; + } + + /** * @param \Magento\Quote\Model\Quote $quote * @return void From 7bf5f4e557de24a29497034f7a3f777a8ffa567d Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Fri, 27 May 2016 18:47:29 +0300 Subject: [PATCH 16/32] MAGETWO-52956: Container miss reference to the mini-cart --- app/code/Magento/Checkout/view/frontend/layout/default.xml | 1 + .../Magento/Checkout/view/frontend/templates/cart/minicart.phtml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/Checkout/view/frontend/layout/default.xml b/app/code/Magento/Checkout/view/frontend/layout/default.xml index 14505e0118eff..06eb85907dda9 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/default.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/default.xml @@ -56,6 +56,7 @@ + diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml index 50c1f1d062731..e089b2a262356 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml @@ -39,6 +39,7 @@
+ getChildHtml('minicart.addons'); ?>