Skip to content

Commit 0c29731

Browse files
Merge branch 'develop' of https://github.com/magento-performance/magento2ce into MAGETWO-64669
2 parents a469104 + 45f2cae commit 0c29731

File tree

203 files changed

+15009
-3702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+15009
-3702
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function execute()
162162
$this->attributeHelper->getStoreWebsiteId($storeId)
163163
);
164164
if (!$stockItemDo->getProductId()) {
165-
$inventoryData[] = $productId;
165+
$inventoryData['product_id'] = $productId;
166166
}
167167

168168
$stockItemId = $stockItemDo->getId();

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
5050
*/
5151
protected $searchCriteriaBuilder;
5252

53-
/**
54-
* @var \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
55-
*/
56-
private $optionManagement;
57-
5853
/**
5954
* @param \Magento\Catalog\Model\ResourceModel\Attribute $attributeResource
6055
* @param \Magento\Catalog\Helper\Product $productHelper
@@ -177,13 +172,31 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
177172
);
178173
$attribute->setIsUserDefined(1);
179174
}
180-
$this->attributeResource->save($attribute);
181-
182175
if (!empty($attribute->getData(AttributeInterface::OPTIONS))) {
176+
$options = [];
177+
$sortOrder = 0;
178+
$default = [];
179+
$optionIndex = 0;
183180
foreach ($attribute->getOptions() as $option) {
184-
$this->getOptionManagement()->add($attribute->getAttributeCode(), $option);
181+
$optionIndex++;
182+
$optionId = $option->getValue() ?: 'option_' . $optionIndex;
183+
$options['value'][$optionId][0] = $option->getLabel();
184+
$options['order'][$optionId] = $option->getSortOrder() ?: $sortOrder++;
185+
if (is_array($option->getStoreLabels())) {
186+
foreach ($option->getStoreLabels() as $label) {
187+
$options['value'][$optionId][$label->getStoreId()] = $label->getLabel();
188+
}
189+
}
190+
if ($option->getIsDefault()) {
191+
$default[] = $optionId;
192+
}
193+
}
194+
$attribute->setDefault($default);
195+
if (count($options)) {
196+
$attribute->setOption($options);
185197
}
186198
}
199+
$this->attributeResource->save($attribute);
187200
return $this->get($attribute->getAttributeCode());
188201
}
189202

@@ -262,16 +275,4 @@ protected function validateFrontendInput($frontendInput)
262275
throw InputException::invalidFieldValue('frontend_input', $frontendInput);
263276
}
264277
}
265-
266-
/**
267-
* @return \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
268-
*/
269-
private function getOptionManagement()
270-
{
271-
if (null === $this->optionManagement) {
272-
$this->optionManagement = \Magento\Framework\App\ObjectManager::getInstance()
273-
->get(\Magento\Catalog\Api\ProductAttributeOptionManagementInterface::class);
274-
}
275-
return $this->optionManagement;
276-
}
277278
}

app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ switch ($type = $block->getType()) {
110110

111111
case 'crosssell':
112112
/** @var \Magento\Catalog\Block\Product\ProductList\Crosssell $block */
113-
if ($exist = $block->getItemCount()) {
113+
if ($exist = count($block->getItems())) {
114114
$type = 'crosssell';
115115
$class = $type;
116116

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ protected function _initAttributeSets()
10151015
protected function _initSkus()
10161016
{
10171017
$this->skuProcessor->setTypeModels($this->_productTypeModels);
1018-
$this->_oldSku = $this->skuProcessor->getOldSkus();
1018+
$this->_oldSku = $this->skuProcessor->reloadOldSkus()->getOldSkus();
10191019
return $this;
10201020
}
10211021

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CatalogImportExport\Model\Import;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Exception\LocalizedException;
910
use Magento\Framework\Filesystem\DriverPool;
1011

1112
/**
@@ -15,6 +16,14 @@
1516
*/
1617
class Uploader extends \Magento\MediaStorage\Model\File\Uploader
1718
{
19+
20+
/**
21+
* HTTP scheme
22+
* used to compare against the filename and select the proper DriverPool adapter
23+
* @var string
24+
*/
25+
private $httpScheme = 'http://';
26+
1827
/**
1928
* Temp directory.
2029
*
@@ -145,7 +154,13 @@ public function move($fileName, $renameFileOff = false)
145154
}
146155
if (preg_match('/\bhttps?:\/\//i', $fileName, $matches)) {
147156
$url = str_replace($matches[0], '', $fileName);
148-
$read = $this->_readFactory->create($url, DriverPool::HTTP);
157+
158+
if ($matches[0] === $this->httpScheme) {
159+
$read = $this->_readFactory->create($url, DriverPool::HTTP);
160+
} else {
161+
$read = $this->_readFactory->create($url, DriverPool::HTTPS);
162+
}
163+
149164
$fileName = preg_replace('/[^a-z0-9\._-]+/i', '', $fileName);
150165
$this->_directory->writeFile(
151166
$this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName),

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ protected function _initTypeModels()
516516
protected function _initSkus()
517517
{
518518
$this->skuProcessor->expects($this->once())->method('setTypeModels');
519+
$this->skuProcessor->expects($this->once())->method('reloadOldSkus')->willReturnSelf();
519520
$this->skuProcessor->expects($this->once())->method('getOldSkus');
520521
return $this;
521522
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,63 @@ public function testMoveFileName()
152152
$this->assertEquals(['name' => $fileName], $this->uploader->move($fileName));
153153
}
154154

155+
/**
156+
* @dataProvider moveFileUrlDriverPoolDataProvider
157+
*/
158+
public function testMoveFileUrlDrivePool($fileUrl, $expectedHost, $expectedDriverPool, $expectedScheme)
159+
{
160+
161+
$driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']);
162+
$driverMock = $this->getMock($expectedDriverPool, ['readAll']);
163+
$driverMock->expects($this->any())->method('isExists')->willReturn(true);
164+
$driverMock->expects($this->any())->method('readAll')->willReturn(null);
165+
$driverPool->expects($this->any())->method('getDriver')->willReturn($driverMock);
166+
167+
$readFactory = $this->getMockBuilder(\Magento\Framework\Filesystem\File\ReadFactory::class)
168+
->setConstructorArgs(
169+
[
170+
$driverPool,
171+
]
172+
)
173+
->setMethods(['create'])
174+
->getMock();
175+
176+
$readFactory->expects($this->any())->method('create')
177+
->with($expectedHost, $expectedScheme)
178+
->willReturn($driverMock);
179+
180+
$uploaderMock = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
181+
->setConstructorArgs([
182+
$this->coreFileStorageDb,
183+
$this->coreFileStorage,
184+
$this->imageFactory,
185+
$this->validator,
186+
$this->filesystem,
187+
$readFactory,
188+
])
189+
->getMock();
190+
191+
$uploaderMock->move($fileUrl);
192+
}
193+
194+
public function moveFileUrlDriverPoolDataProvider()
195+
{
196+
return [
197+
[
198+
'$fileUrl' => 'http://test_uploader_file',
199+
'$expectedHost' => 'test_uploader_file',
200+
'$expectedDriverPool' => \Magento\Framework\Filesystem\Driver\Http::class,
201+
'$expectedScheme' => \Magento\Framework\Filesystem\DriverPool::HTTP,
202+
],
203+
[
204+
'$fileUrl' => 'https://!:^&`;file',
205+
'$expectedHost' => '!:^&`;file',
206+
'$expectedDriverPool' => \Magento\Framework\Filesystem\Driver\Https::class,
207+
'$expectedScheme' => \Magento\Framework\Filesystem\DriverPool::HTTPS,
208+
],
209+
];
210+
}
211+
155212
public function moveFileUrlDataProvider()
156213
{
157214
return [

app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public function getValue()
9999
$this->product->getId()
100100
);
101101
$this->value = $this->value ? floatval($this->value) : false;
102-
if ($this->value) {
103-
$this->value = $this->priceCurrency->convertAndRound($this->value);
104-
}
102+
}
103+
if ($this->value) {
104+
$this->value = $this->priceCurrency->convertAndRound($this->value);
105105
}
106106
}
107107

app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,20 @@ public function testGetValue()
208208

209209
public function testGetValueFromData()
210210
{
211+
$catalogRulePrice = 7.1;
212+
$convertedPrice = 5.84;
213+
214+
$this->priceCurrencyMock->expects($this->any())
215+
->method('convertAndRound')
216+
->with($catalogRulePrice)
217+
->will($this->returnValue($convertedPrice));
218+
211219
$this->saleableItemMock->expects($this->once())->method('hasData')
212220
->with('catalog_rule_price')->willReturn(true);
213221
$this->saleableItemMock->expects($this->once())->method('getData')
214-
->with('catalog_rule_price')->willReturn('7.1');
222+
->with('catalog_rule_price')->willReturn($catalogRulePrice);
215223

216-
$this->assertEquals(7.1, $this->object->getValue());
224+
$this->assertEquals($convertedPrice, $this->object->getValue());
217225
}
218226

219227
public function testGetAmountNoBaseAmount()

app/code/Magento/Checkout/view/frontend/templates/cart/coupon.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"removeCouponSelector": "#remove-coupon",
2020
"applyButton": "button.action.apply",
2121
"cancelButton": "button.action.cancel"}}'>
22-
<div class="fieldset coupon<?php strlen($block->getCouponCode()) ? ' applied' : ''?>">
22+
<div class="fieldset coupon<?php echo strlen($block->getCouponCode()) ? ' applied' : ''?>">
2323
<input type="hidden" name="remove" id="remove-coupon" value="0" />
2424
<div class="field">
2525
<label for="coupon_code" class="label"><span><?php /* @escapeNotVerified */ echo __('Enter discount code') ?></span></label>

0 commit comments

Comments
 (0)