Skip to content

Commit c98c73d

Browse files
author
Onischenko, Yaroslav(yonischenko)
committed
Merge pull request #400 from magento-nord/develop
[NORD] Sprint 35
2 parents 5481fac + 207ac11 commit c98c73d

File tree

19 files changed

+217
-71
lines changed

19 files changed

+217
-71
lines changed

app/code/Magento/Catalog/Test/Unit/Observer/AddCatalogToTopmenuItemsObserverTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,18 @@ public function setUp()
8181
->getMock();
8282

8383
$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Category\Collection')
84-
->disableOriginalConstructor()
84+
->setMethods(
85+
[
86+
'addIsActiveFilter',
87+
'addAttributeToSelect',
88+
'addFieldToFilter',
89+
'addAttributeToFilter',
90+
'addUrlRewriteToResult',
91+
'getIterator'
92+
]
93+
)->disableOriginalConstructor()
8594
->getMock();
86-
95+
$collection->expects($this->once())->method('addIsActiveFilter');
8796
$collectionFactory->expects($this->once())->method('create')
8897
->willReturn($collection);
8998

@@ -151,6 +160,4 @@ public function testAddCatalogToTopMenuItems()
151160
$observer = $this->_preparationData();
152161
$this->_observer->execute($observer);
153162
}
154-
155-
156163
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,9 @@ protected function getCustomOptionsData($productIds)
12301230
$row['price'] = $option['price'];
12311231
$row['price_type'] = ($option['price_type'] == 'percent') ? $option['price_type'] : 'fixed';
12321232
$row['sku'] = $option['sku'];
1233+
if ($option['max_characters']) {
1234+
$row['max_characters'] = $option['max_characters'];
1235+
}
12331236

12341237
$values = $option->getValues();
12351238

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

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
5656
*/
5757
const XML_PATH_PAGE_SIZE = 'import/format_v1/page_size';
5858

59+
/**
60+
* @var string
61+
*/
62+
private $columnMaxCharacters = '_custom_option_max_characters';
63+
5964
/**
6065
* All stores code-ID pairs
6166
*
@@ -1043,9 +1048,7 @@ protected function _isReadyForSaving(array &$options, array &$titles, array $typ
10431048
* Get multiRow format from one line data.
10441049
*
10451050
* @param array $rowData
1046-
*
10471051
* @return array
1048-
* @SuppressWarnings(PHPMD.NPathComplexity)
10491052
*/
10501053
protected function _getMultiRowFormat($rowData)
10511054
{
@@ -1057,34 +1060,61 @@ protected function _getMultiRowFormat($rowData)
10571060
}
10581061

10591062
$i = 0;
1060-
10611063
foreach ($rowData['custom_options'] as $name => $customOption) {
10621064
$i++;
10631065
foreach ($customOption as $rowOrder => $optionRow) {
1064-
$row = [
1065-
self::COLUMN_STORE => '',
1066-
self::COLUMN_TYPE => $name ? $optionRow['type'] : '',
1067-
self::COLUMN_TITLE => $name,
1068-
self::COLUMN_IS_REQUIRED => $optionRow['required'],
1069-
self::COLUMN_SORT_ORDER => $i,
1070-
self::COLUMN_ROW_TITLE => isset($optionRow['option_title']) ? $optionRow['option_title'] : '',
1071-
self::COLUMN_ROW_SKU => $optionRow['sku'],
1072-
self::COLUMN_ROW_SORT => $rowOrder,
1073-
self::COLUMN_PREFIX . 'sku' => $optionRow['sku']
1074-
];
1066+
$row = array_merge(
1067+
[
1068+
self::COLUMN_STORE => '',
1069+
self::COLUMN_TITLE => $name,
1070+
self::COLUMN_SORT_ORDER => $i,
1071+
self::COLUMN_ROW_SORT => $rowOrder
1072+
],
1073+
$this->processOptionRow($name, $optionRow)
1074+
);
1075+
$name = '';
1076+
$multiRow[] = $row;
1077+
}
1078+
}
1079+
1080+
return $multiRow;
1081+
}
10751082

1076-
$percent_suffix = isset($optionRow['price_type']) && ($optionRow['price_type'] == 'percent') ? '%' : '';
1077-
$row[self::COLUMN_ROW_PRICE] = isset($optionRow['price']) ? $optionRow['price'] . $percent_suffix : '';
1078-
$row[self::COLUMN_PREFIX . 'price'] = $row[self::COLUMN_ROW_PRICE];
1083+
/**
1084+
* @param string $name
1085+
* @param array $optionRow
1086+
* @return array
1087+
*/
1088+
private function processOptionRow($name, $optionRow)
1089+
{
1090+
$result = [
1091+
self::COLUMN_TYPE => $name ? $optionRow['type'] : '',
1092+
self::COLUMN_IS_REQUIRED => $optionRow['required'],
1093+
self::COLUMN_ROW_SKU => $optionRow['sku'],
1094+
self::COLUMN_PREFIX . 'sku' => $optionRow['sku'],
1095+
self::COLUMN_ROW_TITLE => '',
1096+
self::COLUMN_ROW_PRICE => ''
1097+
];
10791098

1080-
$name = '';
1099+
if (isset($optionRow['option_title'])) {
1100+
$result[self::COLUMN_ROW_TITLE] = $optionRow['option_title'];
1101+
}
10811102

1082-
$multiRow[] = $row;
1103+
if (isset($optionRow['price'])) {
1104+
$percent_suffix = '';
1105+
if (isset($optionRow['price_type']) && $optionRow['price_type'] == 'percent') {
1106+
$percent_suffix = '%';
10831107
}
1108+
$result[self::COLUMN_ROW_PRICE] = $optionRow['price'] . $percent_suffix;
1109+
}
1110+
1111+
$result[self::COLUMN_PREFIX . 'price'] = $result[self::COLUMN_ROW_PRICE];
10841112

1113+
if (isset($optionRow['max_characters'])) {
1114+
$result[$this->columnMaxCharacters] = $optionRow['max_characters'];
10851115
}
10861116

1087-
return $multiRow;
1117+
return $result;
10881118
}
10891119

10901120
/**

app/code/Magento/Checkout/Block/Cart/Item/Renderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function getMessages()
336336
];
337337
}
338338
}
339-
$this->messageManager->getMessages('quote_item' . $quoteItem->getId())->clear();
339+
$this->messageManager->getMessages(true, 'quote_item' . $quoteItem->getId())->clear();
340340

341341
return $messages;
342342
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento\Customer\Api;
9+
10+
use Magento\Customer\Api\Data\CustomerInterface;
11+
12+
/**
13+
* Interface CustomerNameGenerationInterface
14+
*
15+
* @api
16+
*/
17+
interface CustomerNameGenerationInterface
18+
{
19+
/**
20+
* Concatenate all customer name parts into full customer name.
21+
*
22+
* @param CustomerInterface $customerData
23+
* @return string
24+
*/
25+
public function getCustomerName(CustomerInterface $customerData);
26+
}

app/code/Magento/Customer/Helper/View.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
*/
66
namespace Magento\Customer\Helper;
77

8+
use Magento\Customer\Api\CustomerNameGenerationInterface;
89
use Magento\Customer\Api\CustomerMetadataInterface;
910
use Magento\Customer\Api\Data\CustomerInterface;
1011

1112
/**
1213
* Customer helper for view.
1314
*/
14-
class View extends \Magento\Framework\App\Helper\AbstractHelper
15+
class View extends \Magento\Framework\App\Helper\AbstractHelper implements CustomerNameGenerationInterface
1516
{
1617
/**
1718
* @var CustomerMetadataInterface
@@ -33,10 +34,7 @@ public function __construct(
3334
}
3435

3536
/**
36-
* Concatenate all customer name parts into full customer name.
37-
*
38-
* @param CustomerInterface $customerData
39-
* @return string
37+
* {@inheritdoc}
4038
*/
4139
public function getCustomerName(CustomerInterface $customerData)
4240
{

app/code/Magento/Customer/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
type="Magento\Customer\Model\Metadata\AddressMetadataManagement" />
4444
<preference for="Magento\Customer\Api\CustomerManagementInterface"
4545
type="Magento\Customer\Model\CustomerManagement" />
46+
<preference for="Magento\Customer\Api\CustomerNameGenerationInterface"
47+
type="Magento\Customer\Helper\View" />
4648
<type name="Magento\Customer\Model\Session">
4749
<arguments>
4850
<argument name="configShare" xsi:type="object">Magento\Customer\Model\Config\Share\Proxy</argument>

app/code/Magento/GoogleOptimizer/Model/Plugin/Catalog/Product/Category/DataProvider.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,27 @@ public function __construct(
3434
public function afterGetMeta(NewCategoryDataProvider $subject, $result)
3535
{
3636
$isDisabled = !$this->helper->isGoogleExperimentActive();
37+
$experimentScriptFieldConfig = [
38+
'arguments' => [
39+
'data' => [
40+
'config' => [
41+
'componentDisabled' => $isDisabled
42+
]
43+
]
44+
]
45+
];
3746

38-
$result['data']['children']['experiment_script']['componentDisabled'] = $isDisabled;
39-
$result['data']['children']['code_id']['componentDisabled'] = $isDisabled;
47+
$codeIdFieldConfig = [
48+
'arguments' => [
49+
'data' => [
50+
'config' => [
51+
'componentDisabled' => $isDisabled
52+
]
53+
]
54+
]
55+
];
56+
$result['data']['children']['experiment_script'] = $experimentScriptFieldConfig;
57+
$result['data']['children']['code_id'] = $codeIdFieldConfig;
4058

4159
return $result;
4260
}

app/code/Magento/GoogleOptimizer/Test/Unit/Model/Plugin/Catalog/Product/Category/DataProviderTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ public function testAfterGetMetaPositive()
4848
$this->helper->expects($this->any())->method('isGoogleExperimentActive')->willReturn(true);
4949
$result = $this->plugin->afterGetMeta($this->subject, []);
5050

51-
$this->assertArrayHasKey('experiment_script', $result['data']['children']);
52-
$this->assertFalse($result['data']['children']['experiment_script']['componentDisabled']);
53-
$this->assertArrayHasKey('code_id', $result['data']['children']);
54-
$this->assertFalse($result['data']['children']['code_id']['componentDisabled']);
51+
$children = $result['data']['children'];
52+
$this->assertArrayHasKey('experiment_script', $children);
53+
$this->assertFalse($children['experiment_script']['arguments']['data']['config']['componentDisabled']);
54+
$this->assertArrayHasKey('code_id', $children);
55+
$this->assertFalse($children['code_id']['arguments']['data']['config']['componentDisabled']);
5556
}
5657

5758
public function testAfterGetMetaNegative()
5859
{
5960
$this->helper->expects($this->any())->method('isGoogleExperimentActive')->willReturn(false);
6061
$result = $this->plugin->afterGetMeta($this->subject, []);
6162

62-
$this->assertArrayHasKey('experiment_script', $result['data']['children']);
63-
$this->assertTrue($result['data']['children']['experiment_script']['componentDisabled']);
64-
$this->assertArrayHasKey('code_id', $result['data']['children']);
65-
$this->assertTrue($result['data']['children']['code_id']['componentDisabled']);
63+
$children = $result['data']['children'];
64+
$this->assertArrayHasKey('experiment_script', $children);
65+
$this->assertTrue($children['experiment_script']['arguments']['data']['config']['componentDisabled']);
66+
$this->assertArrayHasKey('code_id', $children);
67+
$this->assertTrue($children['code_id']['arguments']['data']['config']['componentDisabled']);
6668
}
6769
}

app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ define([
335335

336336
_FINISH_UPDATE_INFORMATION_TRIGGER: 'finish_update_information',
337337

338+
_VIDEO_URL_VALIDATE_TRIGGER: 'validate_video_url',
339+
338340
_videoInformation: null,
339341

340342
_currentVideoUrl: null,
@@ -350,6 +352,23 @@ define([
350352
this._currentVideoUrl = null;
351353
}, this
352354
));
355+
this.element.on(this._VIDEO_URL_VALIDATE_TRIGGER, $.proxy(this._onUrlValidateHandler, this));
356+
},
357+
358+
/**
359+
* @private
360+
*/
361+
_onUrlValidateHandler: function (event, callback, forceVideo) {
362+
var url = this.element.val(),
363+
videoInfo;
364+
365+
videoInfo = this._validateURL(url, forceVideo);
366+
367+
if (videoInfo) {
368+
callback();
369+
} else {
370+
this._onRequestError($.mage.__('Invalid video url'));
371+
}
353372
},
354373

355374
/**
@@ -461,7 +480,7 @@ define([
461480
* @private
462481
*/
463482
function _onVimeoLoaded(data) {
464-
var tmp = data[0],
483+
var tmp,
465484
respData;
466485

467486
if (data.length < 1) {

0 commit comments

Comments
 (0)