From 9d2e43613e550eb6ae69ad9e7c20044397687684 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpenko Date: Fri, 30 Oct 2015 13:44:35 +0200 Subject: [PATCH 1/5] MAGETWO-44268: Shipping & Handling is not updated during creating order from admin --- app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php | 1 + app/code/Magento/Quote/Model/Quote/TotalsCollector.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php b/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php index 5295d9f24750f..40f8ff36b08a6 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php +++ b/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php @@ -169,6 +169,7 @@ public function collect( ); $total->setTotalAmount($this->getCode(), $amountPrice); $total->setBaseTotalAmount($this->getCode(), $rate->getPrice()); + $total->setShippingAmount($address->getShippingAmount()); $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle(); $address->setShippingDescription(trim($shippingDescription, ' -')); break; diff --git a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php index 0d7f557e7e7b0..900b6c86f8a99 100644 --- a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php +++ b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php @@ -143,6 +143,9 @@ public function collect(\Magento\Quote\Model\Quote $quote) foreach ($quote->getAllAddresses() as $address) { $addressTotal = $this->collectAddressTotals($quote, $address); + $total->setShippingAmount($addressTotal->getShippingAmount()); + $total->setBaseShippingAmount($addressTotal->getBaseShippingAmount()); + $total->setSubtotal((float)$total->getSubtotal() + $addressTotal->getSubtotal()); $total->setBaseSubtotal((float)$total->getBaseSubtotal() + $addressTotal->getBaseSubtotal()); From 1260725aeba70ea0462038c75c83fc5c26faafc1 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpenko Date: Fri, 30 Oct 2015 16:37:11 +0200 Subject: [PATCH 2/5] MAGETWO-44268: Shipping & Handling is not updated during creating order from admin --- .../Quote/Address/Total/ShippingTest.php | 208 +++++++++++++++++- 1 file changed, 207 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php index 7ea15abed956b..2e244cd017b90 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php @@ -12,10 +12,123 @@ class ShippingTest extends \PHPUnit_Framework_TestCase */ protected $shippingModel; + /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject */ + protected $quote; + + /** @var \Magento\Quote\Model\Quote\Address\Total|\PHPUnit_Framework_MockObject_MockObject */ + protected $total; + + /** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $shippingAssignment; + + /** @var \Magento\Quote\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject */ + protected $address; + + /** @var \Magento\Quote\Api\Data\ShippingInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $shipping; + + /** @var \Magento\Quote\Model\Quote\Address\FreeShippingInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $freeShipping; + + /** @var \Magento\Quote\Api\Data\CartItemInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $cartItem; + + /** @var \Magento\Quote\Model\Quote\Address\Rate|\PHPUnit_Framework_MockObject_MockObject */ + protected $rate; + + /** @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ + protected $store; + + /** @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $priceCurrency; + protected function setUp() { + $this->freeShipping = $this->getMockForAbstractClass( + 'Magento\Quote\Model\Quote\Address\FreeShippingInterface', + [], + '', + false + ); + $this->priceCurrency = $this->getMockForAbstractClass( + 'Magento\Framework\Pricing\PriceCurrencyInterface', + [], + '', + false + ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->shippingModel = $objectManager->getObject('Magento\Quote\Model\Quote\Address\Total\Shipping'); + $this->shippingModel = $objectManager->getObject( + 'Magento\Quote\Model\Quote\Address\Total\Shipping', + [ + 'freeShipping' => $this->freeShipping, + 'priceCurrency' => $this->priceCurrency, + ] + ); + + $this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->total = $this->getMock( + 'Magento\Quote\Model\Quote\Address\Total', + [ + 'setShippingAmount', + 'setBaseTotalAmount', + 'setTotalAmount', + ], + [], + '', + false + ); + $this->shippingAssignment = $this->getMockForAbstractClass( + 'Magento\Quote\Api\Data\ShippingAssignmentInterface', + [], + '', + false + ); + $this->address = $this->getMock( + 'Magento\Quote\Model\Quote\Address', + [ + 'setWeight', + 'setFreeMethodWeight', + 'getWeight', + 'getFreeMethodWeight', + 'setFreeShipping', + 'setItemQty', + 'collectShippingRates', + 'getAllShippingRates', + 'getShippingAmount', + 'setShippingDescription', + 'getFreeShipping', + ], + [], + '', + false + ); + $this->shipping = $this->getMockForAbstractClass('Magento\Quote\Api\Data\ShippingInterface', [], '', false); + $this->cartItem = $this->getMockForAbstractClass( + 'Magento\Quote\Api\Data\CartItemInterface', + [], + '', + false, + false, + true, + [ + 'getFreeShipping', + 'getProduct', + 'getParentItem', + 'getHasChildren', + 'isVirtual', + 'getWeight', + 'getQty', + 'setRowWeight', + ] + ); + $this->rate = $this->getMock( + 'Magento\Quote\Model\Quote\Address\Rate', + ['getPrice', 'getCode', 'getCarrierTitle', 'getMethodTitle'], + [], + '', + false + ); + $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); } public function testFetch() @@ -41,4 +154,97 @@ public function testFetch() $totalMock->expects($this->once())->method('getShippingDescription')->willReturn($shippingDescription); $this->assertEquals($expectedResult, $this->shippingModel->fetch($quoteMock, $totalMock)); } + + public function testCollect() + { + $this->shippingAssignment->expects($this->exactly(3)) + ->method('getShipping') + ->willReturn($this->shipping); + $this->shipping->expects($this->exactly(2)) + ->method('getAddress') + ->willReturn($this->address); + $this->shipping->expects($this->once()) + ->method('getMethod') + ->willReturn('flatrate'); + $this->shippingAssignment->expects($this->atLeastOnce()) + ->method('getItems') + ->willReturn([$this->cartItem]); + $this->freeShipping->expects($this->once()) + ->method('isFreeShipping') + ->with($this->quote, [$this->cartItem]) + ->willReturn(true); + $this->address->expects($this->once()) + ->method('setFreeShipping') + ->with(true); + $this->total->expects($this->atLeastOnce()) + ->method('setTotalAmount'); + $this->total->expects($this->atLeastOnce()) + ->method('setBaseTotalAmount'); + $this->cartItem->expects($this->atLeastOnce()) + ->method('getProduct') + ->willReturnSelf(); + $this->cartItem->expects($this->atLeastOnce()) + ->method('isVirtual') + ->willReturn(false); + $this->cartItem->expects($this->once()) + ->method('getParentItem') + ->willReturn(false); + $this->cartItem->expects($this->once()) + ->method('getHasChildren') + ->willReturn(false); + $this->cartItem->expects($this->once()) + ->method('getWeight') + ->willReturn(2); + $this->cartItem->expects($this->atLeastOnce()) + ->method('getQty') + ->willReturn(2); + $this->address->expects($this->once()) + ->method('getFreeShipping') + ->willReturn(true); + $this->cartItem->expects($this->once()) + ->method('setRowWeight') + ->with(0); + $this->address->expects($this->once()) + ->method('setItemQty') + ->with(2); + $this->address->expects($this->atLeastOnce()) + ->method('setWeight'); + $this->address->expects($this->atLeastOnce()) + ->method('setFreeMethodWeight'); + $this->address->expects($this->once()) + ->method('collectShippingRates'); + $this->address->expects($this->once()) + ->method('getAllShippingRates') + ->willReturn([$this->rate]); + $this->rate->expects($this->once()) + ->method('getCode') + ->willReturn('flatrate'); + $this->quote->expects($this->once()) + ->method('getStore') + ->willReturn($this->store); + $this->rate->expects($this->atLeastOnce()) + ->method('getPrice') + ->willReturn(5); + $this->priceCurrency->expects($this->once()) + ->method('convert') + ->with(5, $this->store) + ->willReturn(5); + $this->address->expects($this->once()) + ->method('getShippingAmount') + ->willReturn(5); + $this->total->expects($this->once()) + ->method('setShippingAmount') + ->with(5); + $this->rate->expects($this->once()) + ->method('getCarrierTitle') + ->willReturn('Carrier title'); + $this->rate->expects($this->once()) + ->method('getMethodTitle') + ->willReturn('Method title'); + $this->address->expects($this->once()) + ->method('setShippingDescription') + ->with('Carrier title - Method title'); + + $this->shippingModel->collect($this->quote, $this->shippingAssignment, $this->total); + } } From e87f2675e25629b0f84604bdecc36003557e284b Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Fri, 30 Oct 2015 16:45:18 +0200 Subject: [PATCH 3/5] MAGETWO-44775: [GITHUB] system > import > customers sample data files missing #1840 --- app/code/Magento/ImportExport/Files/Sample/customer.csv | 2 ++ app/code/Magento/ImportExport/Files/Sample/customer_address.csv | 2 ++ app/code/Magento/ImportExport/Files/Sample/customer_finance.csv | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 app/code/Magento/ImportExport/Files/Sample/customer.csv create mode 100644 app/code/Magento/ImportExport/Files/Sample/customer_address.csv create mode 100644 app/code/Magento/ImportExport/Files/Sample/customer_finance.csv diff --git a/app/code/Magento/ImportExport/Files/Sample/customer.csv b/app/code/Magento/ImportExport/Files/Sample/customer.csv new file mode 100644 index 0000000000000..64c09574aea73 --- /dev/null +++ b/app/code/Magento/ImportExport/Files/Sample/customer.csv @@ -0,0 +1,2 @@ +email,_website,_store,confirmation,created_at,created_in,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,reward_update_notification,reward_warning_notification,rp_token,rp_token_created_at,store_id,suffix,taxvat,updated_at,website_id,password +jondoe@example.com,base,default,,"2015-10-30 12:49:47","Default Store View",0,,Jon,,1,Doe,,d708be3fe0fe0120840e8b13c8faae97424252c6374227ff59c05814f1aecd79:mgLqkqgTwLPLlCljzvF8hp67fNOOvOZb:1,,,,07e71459c137f4da15292134ff459cba,"2015-10-30 12:49:48",1,,,"2015-10-30 12:49:48",1, diff --git a/app/code/Magento/ImportExport/Files/Sample/customer_address.csv b/app/code/Magento/ImportExport/Files/Sample/customer_address.csv new file mode 100644 index 0000000000000..ca7318e7f7545 --- /dev/null +++ b/app/code/Magento/ImportExport/Files/Sample/customer_address.csv @@ -0,0 +1,2 @@ +_website,_email,_entity_id,city,company,country_id,fax,firstname,lastname,middlename,postcode,prefix,region,region_id,street,suffix,telephone,vat_id,vat_is_valid,vat_request_date,vat_request_id,vat_request_success,_address_default_billing_,_address_default_shipping_ +base,jondoe@example.com,1,"New York",,US,,Jon,Doe,,10044,,"New York",43,"Main Street 1",,123456789,,,,,,1,1 diff --git a/app/code/Magento/ImportExport/Files/Sample/customer_finance.csv b/app/code/Magento/ImportExport/Files/Sample/customer_finance.csv new file mode 100644 index 0000000000000..926f29ecfc5eb --- /dev/null +++ b/app/code/Magento/ImportExport/Files/Sample/customer_finance.csv @@ -0,0 +1,2 @@ +_email,_website,_finance_website,store_credit,reward_points +jondoe@example.com,base,base,10.0000,100 From daf845a312f25a5bfbd39805e2b99ef62fe0156a Mon Sep 17 00:00:00 2001 From: Oleksandr Karpenko Date: Fri, 30 Oct 2015 17:33:09 +0200 Subject: [PATCH 4/5] MAGETWO-44268: Shipping & Handling is not updated during creating order from admin --- .../Quote/Model/Quote/Address/Total/Shipping.php | 4 +++- .../Magento/Quote/Model/Quote/TotalsCollector.php | 1 + .../Unit/Model/Quote/Address/Total/ShippingTest.php | 12 ++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php b/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php index 40f8ff36b08a6..8b082e0eff7f3 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php +++ b/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php @@ -169,9 +169,10 @@ public function collect( ); $total->setTotalAmount($this->getCode(), $amountPrice); $total->setBaseTotalAmount($this->getCode(), $rate->getPrice()); - $total->setShippingAmount($address->getShippingAmount()); $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle(); $address->setShippingDescription(trim($shippingDescription, ' -')); + $total->setShippingAmount($rate->getPrice()); + $total->setShippingDescription($address->getShippingDescription()); break; } } @@ -185,6 +186,7 @@ public function collect( * @param \Magento\Quote\Model\Quote $quote * @param \Magento\Quote\Model\Quote\Address\Total $total * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total) { diff --git a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php index 900b6c86f8a99..a7fd15786d040 100644 --- a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php +++ b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php @@ -145,6 +145,7 @@ public function collect(\Magento\Quote\Model\Quote $quote) $total->setShippingAmount($addressTotal->getShippingAmount()); $total->setBaseShippingAmount($addressTotal->getBaseShippingAmount()); + $total->setShippingDescription($addressTotal->getShippingDescription()); $total->setSubtotal((float)$total->getSubtotal() + $addressTotal->getSubtotal()); $total->setBaseSubtotal((float)$total->getBaseSubtotal() + $addressTotal->getBaseSubtotal()); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php index 2e244cd017b90..2477523ef9ee0 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php @@ -72,6 +72,7 @@ protected function setUp() 'setShippingAmount', 'setBaseTotalAmount', 'setTotalAmount', + 'setShippingDescription', ], [], '', @@ -94,8 +95,8 @@ protected function setUp() 'setItemQty', 'collectShippingRates', 'getAllShippingRates', - 'getShippingAmount', 'setShippingDescription', + 'getShippingDescription', 'getFreeShipping', ], [], @@ -229,9 +230,6 @@ public function testCollect() ->method('convert') ->with(5, $this->store) ->willReturn(5); - $this->address->expects($this->once()) - ->method('getShippingAmount') - ->willReturn(5); $this->total->expects($this->once()) ->method('setShippingAmount') ->with(5); @@ -244,6 +242,12 @@ public function testCollect() $this->address->expects($this->once()) ->method('setShippingDescription') ->with('Carrier title - Method title'); + $this->address->expects($this->once()) + ->method('getShippingDescription') + ->willReturn('Carrier title - Method title'); + $this->total->expects($this->once()) + ->method('setShippingDescription') + ->with('Carrier title - Method title'); $this->shippingModel->collect($this->quote, $this->shippingAssignment, $this->total); } From 2f058b8a7b38ac525a1059ba011aec8946cbf4af Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Fri, 30 Oct 2015 18:20:02 +0200 Subject: [PATCH 5/5] MAGETWO-44795: Customer Grid index isn't invalidated after any customer related import --- app/code/Magento/CustomerImportExport/etc/import.xml | 3 +++ app/code/Magento/ImportExport/Model/Import/Config/Reader.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CustomerImportExport/etc/import.xml b/app/code/Magento/CustomerImportExport/etc/import.xml index 5c625b53804b2..d5080cf170dbc 100644 --- a/app/code/Magento/CustomerImportExport/etc/import.xml +++ b/app/code/Magento/CustomerImportExport/etc/import.xml @@ -9,4 +9,7 @@ + + + diff --git a/app/code/Magento/ImportExport/Model/Import/Config/Reader.php b/app/code/Magento/ImportExport/Model/Import/Config/Reader.php index 08ef93bbd6881..2d064c466aab4 100644 --- a/app/code/Magento/ImportExport/Model/Import/Config/Reader.php +++ b/app/code/Magento/ImportExport/Model/Import/Config/Reader.php @@ -15,7 +15,7 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem protected $_idAttributes = [ '/config/entity' => 'name', '/config/entityType' => ['entity', 'name'], - '/config/relatedIndexers' => ['entity', 'name'], + '/config/relatedIndexer' => ['entity', 'name'], ]; /**