Skip to content

Commit 480227c

Browse files
committed
Merge remote-tracking branches 'tsg/MAGETWO-61226', 'tsg/MAGETWO-64962', 'tsg/MAGETWO-67343', 'tsg/MAGETWO-59249', 'tsg/MAGETWO-61060', 'tsg/MAGETWO-63033' and 'tsg/MAGETWO-64676' into 2.0.16-develop-pr15
8 parents 8ce538f + b5dba62 + f2f7d7b + 9cceaef + 9485757 + 742c25f + 2a3e49b + 5319a6f commit 480227c

File tree

19 files changed

+527
-73
lines changed

19 files changed

+527
-73
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ define([
5555

5656
if (render) {
5757
this.render();
58+
this.updateItemsCountField();
5859
}
5960
},
6061
remove: function (event) {

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,14 +772,20 @@ protected function getItemsPerPage()
772772
$memoryUsagePercent = 0.8;
773773
// Minimum Products limit
774774
$minProductsLimit = 500;
775+
// Maximal Products limit
776+
$maxProductsLimit = 3000;
775777

776778
$this->_itemsPerPage = intval(
777779
($memoryLimit * $memoryUsagePercent - memory_get_usage(true)) / $memoryPerProduct
778780
);
779781
if ($this->_itemsPerPage < $minProductsLimit) {
780782
$this->_itemsPerPage = $minProductsLimit;
781783
}
784+
if ($this->_itemsPerPage > $maxProductsLimit) {
785+
$this->_itemsPerPage = $maxProductsLimit;
786+
}
782787
}
788+
783789
return $this->_itemsPerPage;
784790
}
785791

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,10 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
558558
/** @var array */
559559
protected $productUrlSuffix = [];
560560

561-
/** @var array */
561+
/**
562+
* @var array
563+
* @deprecated
564+
*/
562565
protected $productUrlKeys = [];
563566

564567
/**
@@ -1499,6 +1502,10 @@ protected function _saveProducts()
14991502
}
15001503
$rowScope = $this->getRowScope($rowData);
15011504

1505+
if (empty($rowData[self::URL_KEY])) {
1506+
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
1507+
}
1508+
15021509
$rowSku = $rowData[self::COL_SKU];
15031510

15041511
if (null === $rowSku) {
@@ -2630,18 +2637,22 @@ protected function getProductUrlSuffix($storeId = null)
26302637
}
26312638

26322639
/**
2640+
* Return url key if specified, or generate one from product name otherwise.
2641+
*
26332642
* @param array $rowData
26342643
* @return string
26352644
*/
26362645
protected function getUrlKey($rowData)
26372646
{
26382647
if (!empty($rowData[self::URL_KEY])) {
2639-
$this->productUrlKeys[$rowData[self::COL_SKU]] = $rowData[self::URL_KEY];
2648+
return $rowData[self::URL_KEY];
26402649
}
2641-
$urlKey = !empty($this->productUrlKeys[$rowData[self::COL_SKU]])
2642-
? $this->productUrlKeys[$rowData[self::COL_SKU]]
2643-
: $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
2644-
return $urlKey;
2650+
2651+
if (!empty($rowData[self::COL_NAME])) {
2652+
return $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
2653+
}
2654+
2655+
return '';
26452656
}
26462657

26472658
/**

app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Framework\Exception\LocalizedException;
99
use Magento\Quote\Model\Quote\Address\RateRequest;
1010

11+
/**
12+
* Table rate shipping model.
13+
*/
1114
class Tablerate extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
1215
\Magento\Shipping\Model\Carrier\CarrierInterface
1316
{
@@ -151,25 +154,31 @@ public function collectRates(RateRequest $request)
151154
$request->setPackageQty($oldQty);
152155

153156
if (!empty($rate) && $rate['price'] >= 0) {
154-
/** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */
155-
$method = $this->_resultMethodFactory->create();
156-
157-
$method->setCarrier('tablerate');
158-
$method->setCarrierTitle($this->getConfigData('title'));
159-
160-
$method->setMethod('bestway');
161-
$method->setMethodTitle($this->getConfigData('name'));
162-
163157
if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
164158
$shippingPrice = 0;
165159
} else {
166160
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
167161
}
168162

169-
$method->setPrice($shippingPrice);
170-
$method->setCost($rate['cost']);
163+
$method = $this->createShippingMethod($shippingPrice, $rate['cost']);
171164

172165
$result->append($method);
166+
} elseif (empty($rate) && $request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
167+
/**
168+
* Promotion rule was applied for the whole cart.
169+
* In this case all other shipping methods could be omitted.
170+
* Table rate shipping method with 0$ price must be shown if grand total is more than minimal value.
171+
* Free package weight has been already taken into account.
172+
*/
173+
$request->setPackageValue($freePackageValue);
174+
$request->setPackageQty($freeQty);
175+
176+
$rate = $this->getRate($request);
177+
178+
if (!empty($rate) && $rate['price'] >= 0) {
179+
$method = $this->createShippingMethod(0, 0);
180+
$result->append($method);
181+
}
173182
} else {
174183
/** @var \Magento\Quote\Model\Quote\Address\RateResult\Error $error */
175184
$error = $this->_rateErrorFactory->create(
@@ -233,12 +242,33 @@ public function getCode($type, $code = '')
233242
}
234243

235244
/**
236-
* Get allowed shipping methods
245+
* Get allowed shipping methods.
237246
*
238247
* @return array
239248
*/
240249
public function getAllowedMethods()
241250
{
242251
return ['bestway' => $this->getConfigData('name')];
243252
}
253+
254+
/**
255+
* Get the method object based on the shipping price and cost.
256+
*
257+
* @param float $shippingPrice
258+
* @param float $cost
259+
* @return \Magento\Quote\Model\Quote\Address\RateResult\Method
260+
*/
261+
private function createShippingMethod($shippingPrice, $cost)
262+
{
263+
/** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */
264+
$method = $this->_resultMethodFactory->create();
265+
$method->setCarrier('tablerate');
266+
$method->setCarrierTitle($this->getConfigData('title'));
267+
$method->setMethod('bestway');
268+
$method->setMethodTitle($this->getConfigData('name'));
269+
$method->setPrice($shippingPrice);
270+
$method->setCost($cost);
271+
272+
return $method;
273+
}
244274
}

app/code/Magento/Sitemap/Model/Sitemap.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function __construct(
201201
*/
202202
protected function _construct()
203203
{
204-
$this->_init('Magento\Sitemap\Model\ResourceModel\Sitemap');
204+
$this->_init(\Magento\Sitemap\Model\ResourceModel\Sitemap::class);
205205
}
206206

207207
/**
@@ -586,7 +586,12 @@ protected function _getBaseDir()
586586
*/
587587
protected function _getStoreBaseUrl($type = \Magento\Framework\UrlInterface::URL_TYPE_LINK)
588588
{
589-
return rtrim($this->_storeManager->getStore($this->getStoreId())->getBaseUrl($type), '/') . '/';
589+
/** @var \Magento\Store\Model\Store $store */
590+
$store = $this->_storeManager->getStore($this->getStoreId());
591+
592+
$isSecure = $store->isUrlSecure();
593+
594+
return rtrim($store->getBaseUrl($type, $isSecure), '/') . '/';
590595
}
591596

592597
/**

app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,27 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
5050
*/
5151
protected $_fileMock;
5252

53+
/**
54+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
private $storeManagerMock;
57+
5358
/**
5459
* Set helper mocks, create resource model mock
5560
*/
5661
protected function setUp()
5762
{
5863
$this->_sitemapCategoryMock = $this->getMockBuilder(
59-
'Magento\Sitemap\Model\ResourceModel\Catalog\Category'
64+
\Magento\Sitemap\Model\ResourceModel\Catalog\Category::class
6065
)->disableOriginalConstructor()->getMock();
6166
$this->_sitemapProductMock = $this->getMockBuilder(
62-
'Magento\Sitemap\Model\ResourceModel\Catalog\Product'
67+
\Magento\Sitemap\Model\ResourceModel\Catalog\Product::class
6368
)->disableOriginalConstructor()->getMock();
6469
$this->_sitemapCmsPageMock = $this->getMockBuilder(
65-
'Magento\Sitemap\Model\ResourceModel\Cms\Page'
70+
\Magento\Sitemap\Model\ResourceModel\Cms\Page::class
6671
)->disableOriginalConstructor()->getMock();
6772
$this->_helperMockSitemap = $this->getMock(
68-
'Magento\Sitemap\Helper\Data',
73+
\Magento\Sitemap\Helper\Data::class,
6974
[
7075
'getCategoryChangefreq',
7176
'getProductChangefreq',
@@ -114,23 +119,23 @@ protected function setUp()
114119
$this->_helperMockSitemap->expects($this->any())->method('getPagePriority')->will($this->returnValue('0.25'));
115120

116121
$this->_resourceMock = $this->getMockBuilder(
117-
'Magento\Sitemap\Model\ResourceModel\Sitemap'
122+
\Magento\Sitemap\Model\ResourceModel\Sitemap::class
118123
)->setMethods(
119124
['_construct', 'beginTransaction', 'rollBack', 'save', 'addCommitCallback', 'commit', '__wakeup']
120125
)->disableOriginalConstructor()->getMock();
121126
$this->_resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
122127

123128
$this->_fileMock = $this->getMockBuilder(
124-
'Magento\Framework\Filesystem\File\Write'
129+
\Magento\Framework\Filesystem\File\Write::class
125130
)->disableOriginalConstructor()->getMock();
126131

127132
$this->_directoryMock = $this->getMockBuilder(
128-
'Magento\Framework\Filesystem\Directory\Write'
133+
\Magento\Framework\Filesystem\Directory\Write::class
129134
)->disableOriginalConstructor()->getMock();
130135
$this->_directoryMock->expects($this->any())->method('openFile')->will($this->returnValue($this->_fileMock));
131136

132137
$this->_filesystemMock = $this->getMockBuilder(
133-
'Magento\Framework\Filesystem'
138+
\Magento\Framework\Filesystem::class
134139
)->setMethods(
135140
['getDirectoryWrite']
136141
)->disableOriginalConstructor()->getMock();
@@ -473,6 +478,20 @@ function ($from, $to) {
473478

474479
$model = $this->_getModelMock(true);
475480

481+
$storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
482+
->setMethods(['isFrontUrlSecure', 'getBaseUrl'])
483+
->disableOriginalConstructor()
484+
->getMock();
485+
$storeMock->expects($this->atLeastOnce())->method('isFrontUrlSecure')->willReturn(false);
486+
$storeMock->expects($this->atLeastOnce())
487+
->method('getBaseUrl')
488+
->with($this->isType('string'), false)
489+
->willReturn('http://store.com/');
490+
$this->storeManagerMock->expects($this->atLeastOnce())
491+
->method('getStore')
492+
->with(1)
493+
->willReturn($storeMock);
494+
476495
return $model;
477496
}
478497

@@ -490,7 +509,6 @@ protected function _getModelMock($mockBeforeSave = false)
490509
'_getBaseDir',
491510
'_getFileObject',
492511
'_afterSave',
493-
'_getStoreBaseUrl',
494512
'_getCurrentDateTime',
495513
'_getCategoryItemsCollection',
496514
'_getProductItemsCollection',
@@ -554,15 +572,14 @@ protected function _getModelMock($mockBeforeSave = false)
554572

555573
/** @var $model \Magento\Sitemap\Model\Sitemap */
556574
$model = $this->getMockBuilder(
557-
'Magento\Sitemap\Model\Sitemap'
575+
\Magento\Sitemap\Model\Sitemap::class
558576
)->setMethods(
559577
$methods
560578
)->setConstructorArgs(
561579
$this->_getModelConstructorArgs()
562580
)->getMock();
563581

564582
$model->expects($this->any())->method('_getResource')->will($this->returnValue($this->_resourceMock));
565-
$model->expects($this->any())->method('_getStoreBaseUrl')->will($this->returnValue('http://store.com/'));
566583
$model->expects(
567584
$this->any()
568585
)->method(
@@ -585,7 +602,7 @@ protected function _getModelMock($mockBeforeSave = false)
585602
protected function _getModelConstructorArgs()
586603
{
587604
$categoryFactory = $this->getMockBuilder(
588-
'Magento\Sitemap\Model\ResourceModel\Catalog\CategoryFactory'
605+
\Magento\Sitemap\Model\ResourceModel\Catalog\CategoryFactory::class
589606
)->setMethods(
590607
['create']
591608
)->disableOriginalConstructor()->getMock();
@@ -598,26 +615,31 @@ protected function _getModelConstructorArgs()
598615
);
599616

600617
$productFactory = $this->getMockBuilder(
601-
'Magento\Sitemap\Model\ResourceModel\Catalog\ProductFactory'
618+
\Magento\Sitemap\Model\ResourceModel\Catalog\ProductFactory::class
602619
)->setMethods(
603620
['create']
604621
)->disableOriginalConstructor()->getMock();
605622
$productFactory->expects($this->any())->method('create')->will($this->returnValue($this->_sitemapProductMock));
606623

607624
$cmsFactory = $this->getMockBuilder(
608-
'Magento\Sitemap\Model\ResourceModel\Cms\PageFactory'
625+
\Magento\Sitemap\Model\ResourceModel\Cms\PageFactory::class
609626
)->setMethods(
610627
['create']
611628
)->disableOriginalConstructor()->getMock();
612629
$cmsFactory->expects($this->any())->method('create')->will($this->returnValue($this->_sitemapCmsPageMock));
613630

631+
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
632+
->setMethods(['getStore'])
633+
->getMockForAbstractClass();
634+
614635
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
615636
$constructArguments = $objectManager->getConstructArguments(
616-
'Magento\Sitemap\Model\Sitemap',
637+
\Magento\Sitemap\Model\Sitemap::class,
617638
[
618639
'categoryFactory' => $categoryFactory,
619640
'productFactory' => $productFactory,
620641
'cmsFactory' => $cmsFactory,
642+
'storeManager' => $this->storeManagerMock,
621643
'sitemapData' => $this->_helperMockSitemap,
622644
'filesystem' => $this->_filesystemMock
623645
]
@@ -641,7 +663,7 @@ public function testGetSitemapUrl($storeBaseUrl, $documentRoot, $baseDir, $sitem
641663
{
642664
/** @var $model \Magento\Sitemap\Model\Sitemap */
643665
$model = $this->getMockBuilder(
644-
'Magento\Sitemap\Model\Sitemap'
666+
\Magento\Sitemap\Model\Sitemap::class
645667
)->setMethods(
646668
['_getStoreBaseUrl', '_getDocumentRoot', '_getBaseDir', '_construct']
647669
)->setConstructorArgs(

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeIsUnique.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,16 @@ public function processAssert(
5858
$productForm = $catalogProductEdit->getProductForm();
5959
$productForm->fill($simpleProduct);
6060
$catalogProductEdit->getFormPageActions()->save();
61-
$failedAttributes = $productForm->getRequireNoticeAttributes($simpleProduct);
61+
$actualErrorMessage = $catalogProductEdit->getMessagesBlock()->getErrorMessage();
6262
$attributeLabel = $attribute->getFrontendLabel();
63-
$actualMessage = $this->getActualMessage($failedAttributes, $attributeLabel);
6463

6564
\PHPUnit_Framework_Assert::assertEquals(
6665
sprintf(self::UNIQUE_MESSAGE, $attributeLabel),
67-
$actualMessage,
66+
$actualErrorMessage,
6867
'JS error notice on product edit page is not equal to expected.'
6968
);
7069
}
7170

72-
/**
73-
* Get actual message.
74-
*
75-
* @param array $errors
76-
* @param string $attributeLabel
77-
* @return mixed
78-
*/
79-
protected function getActualMessage(array $errors, $attributeLabel)
80-
{
81-
return isset($errors['product-details'][$attributeLabel])
82-
? $errors['product-details'][$attributeLabel]
83-
: null;
84-
}
85-
8671
/**
8772
* Create simple product fixture.
8873
*

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Review.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
namespace Magento\Checkout\Test\Block\Onepage;
88

9-
use Magento\Checkout\Test\Block\Onepage\AbstractReview;
10-
119
/**
1210
* One page checkout status review block.
1311
*/
1412
class Review extends AbstractReview
1513
{
16-
//
14+
1715
}

0 commit comments

Comments
 (0)