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/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 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'], ]; /** 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..8b082e0eff7f3 100644 --- a/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php +++ b/app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php @@ -171,6 +171,8 @@ public function collect( $total->setBaseTotalAmount($this->getCode(), $rate->getPrice()); $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle(); $address->setShippingDescription(trim($shippingDescription, ' -')); + $total->setShippingAmount($rate->getPrice()); + $total->setShippingDescription($address->getShippingDescription()); break; } } @@ -184,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 0d7f557e7e7b0..a7fd15786d040 100644 --- a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php +++ b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php @@ -143,6 +143,10 @@ 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->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 7ea15abed956b..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 @@ -12,10 +12,124 @@ 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', + 'setShippingDescription', + ], + [], + '', + 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', + 'setShippingDescription', + 'getShippingDescription', + '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 +155,100 @@ 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->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->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); + } }