Skip to content

Commit

Permalink
Merge pull request #400 from magento-nord/develop
Browse files Browse the repository at this point in the history
[NORD] Sprint 35
  • Loading branch information
Onischenko, Yaroslav(yonischenko) committed Mar 9, 2016
2 parents 5481fac + 207ac11 commit c98c73d
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,18 @@ public function setUp()
->getMock();

$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Category\Collection')
->disableOriginalConstructor()
->setMethods(
[
'addIsActiveFilter',
'addAttributeToSelect',
'addFieldToFilter',
'addAttributeToFilter',
'addUrlRewriteToResult',
'getIterator'
]
)->disableOriginalConstructor()
->getMock();

$collection->expects($this->once())->method('addIsActiveFilter');
$collectionFactory->expects($this->once())->method('create')
->willReturn($collection);

Expand Down Expand Up @@ -151,6 +160,4 @@ public function testAddCatalogToTopMenuItems()
$observer = $this->_preparationData();
$this->_observer->execute($observer);
}


}
3 changes: 3 additions & 0 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,9 @@ protected function getCustomOptionsData($productIds)
$row['price'] = $option['price'];
$row['price_type'] = ($option['price_type'] == 'percent') ? $option['price_type'] : 'fixed';
$row['sku'] = $option['sku'];
if ($option['max_characters']) {
$row['max_characters'] = $option['max_characters'];
}

$values = $option->getValues();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
*/
const XML_PATH_PAGE_SIZE = 'import/format_v1/page_size';

/**
* @var string
*/
private $columnMaxCharacters = '_custom_option_max_characters';

/**
* All stores code-ID pairs
*
Expand Down Expand Up @@ -1043,9 +1048,7 @@ protected function _isReadyForSaving(array &$options, array &$titles, array $typ
* Get multiRow format from one line data.
*
* @param array $rowData
*
* @return array
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _getMultiRowFormat($rowData)
{
Expand All @@ -1057,34 +1060,61 @@ protected function _getMultiRowFormat($rowData)
}

$i = 0;

foreach ($rowData['custom_options'] as $name => $customOption) {
$i++;
foreach ($customOption as $rowOrder => $optionRow) {
$row = [
self::COLUMN_STORE => '',
self::COLUMN_TYPE => $name ? $optionRow['type'] : '',
self::COLUMN_TITLE => $name,
self::COLUMN_IS_REQUIRED => $optionRow['required'],
self::COLUMN_SORT_ORDER => $i,
self::COLUMN_ROW_TITLE => isset($optionRow['option_title']) ? $optionRow['option_title'] : '',
self::COLUMN_ROW_SKU => $optionRow['sku'],
self::COLUMN_ROW_SORT => $rowOrder,
self::COLUMN_PREFIX . 'sku' => $optionRow['sku']
];
$row = array_merge(
[
self::COLUMN_STORE => '',
self::COLUMN_TITLE => $name,
self::COLUMN_SORT_ORDER => $i,
self::COLUMN_ROW_SORT => $rowOrder
],
$this->processOptionRow($name, $optionRow)
);
$name = '';
$multiRow[] = $row;
}
}

return $multiRow;
}

$percent_suffix = isset($optionRow['price_type']) && ($optionRow['price_type'] == 'percent') ? '%' : '';
$row[self::COLUMN_ROW_PRICE] = isset($optionRow['price']) ? $optionRow['price'] . $percent_suffix : '';
$row[self::COLUMN_PREFIX . 'price'] = $row[self::COLUMN_ROW_PRICE];
/**
* @param string $name
* @param array $optionRow
* @return array
*/
private function processOptionRow($name, $optionRow)
{
$result = [
self::COLUMN_TYPE => $name ? $optionRow['type'] : '',
self::COLUMN_IS_REQUIRED => $optionRow['required'],
self::COLUMN_ROW_SKU => $optionRow['sku'],
self::COLUMN_PREFIX . 'sku' => $optionRow['sku'],
self::COLUMN_ROW_TITLE => '',
self::COLUMN_ROW_PRICE => ''
];

$name = '';
if (isset($optionRow['option_title'])) {
$result[self::COLUMN_ROW_TITLE] = $optionRow['option_title'];
}

$multiRow[] = $row;
if (isset($optionRow['price'])) {
$percent_suffix = '';
if (isset($optionRow['price_type']) && $optionRow['price_type'] == 'percent') {
$percent_suffix = '%';
}
$result[self::COLUMN_ROW_PRICE] = $optionRow['price'] . $percent_suffix;
}

$result[self::COLUMN_PREFIX . 'price'] = $result[self::COLUMN_ROW_PRICE];

if (isset($optionRow['max_characters'])) {
$result[$this->columnMaxCharacters] = $optionRow['max_characters'];
}

return $multiRow;
return $result;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Block/Cart/Item/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function getMessages()
];
}
}
$this->messageManager->getMessages('quote_item' . $quoteItem->getId())->clear();
$this->messageManager->getMessages(true, 'quote_item' . $quoteItem->getId())->clear();

return $messages;
}
Expand Down
26 changes: 26 additions & 0 deletions app/code/Magento/Customer/Api/CustomerNameGenerationInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
*
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Api;

use Magento\Customer\Api\Data\CustomerInterface;

/**
* Interface CustomerNameGenerationInterface
*
* @api
*/
interface CustomerNameGenerationInterface
{
/**
* Concatenate all customer name parts into full customer name.
*
* @param CustomerInterface $customerData
* @return string
*/
public function getCustomerName(CustomerInterface $customerData);
}
8 changes: 3 additions & 5 deletions app/code/Magento/Customer/Helper/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/
namespace Magento\Customer\Helper;

use Magento\Customer\Api\CustomerNameGenerationInterface;
use Magento\Customer\Api\CustomerMetadataInterface;
use Magento\Customer\Api\Data\CustomerInterface;

/**
* Customer helper for view.
*/
class View extends \Magento\Framework\App\Helper\AbstractHelper
class View extends \Magento\Framework\App\Helper\AbstractHelper implements CustomerNameGenerationInterface
{
/**
* @var CustomerMetadataInterface
Expand All @@ -33,10 +34,7 @@ public function __construct(
}

/**
* Concatenate all customer name parts into full customer name.
*
* @param CustomerInterface $customerData
* @return string
* {@inheritdoc}
*/
public function getCustomerName(CustomerInterface $customerData)
{
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Customer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
type="Magento\Customer\Model\Metadata\AddressMetadataManagement" />
<preference for="Magento\Customer\Api\CustomerManagementInterface"
type="Magento\Customer\Model\CustomerManagement" />
<preference for="Magento\Customer\Api\CustomerNameGenerationInterface"
type="Magento\Customer\Helper\View" />
<type name="Magento\Customer\Model\Session">
<arguments>
<argument name="configShare" xsi:type="object">Magento\Customer\Model\Config\Share\Proxy</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,27 @@ public function __construct(
public function afterGetMeta(NewCategoryDataProvider $subject, $result)
{
$isDisabled = !$this->helper->isGoogleExperimentActive();
$experimentScriptFieldConfig = [
'arguments' => [
'data' => [
'config' => [
'componentDisabled' => $isDisabled
]
]
]
];

$result['data']['children']['experiment_script']['componentDisabled'] = $isDisabled;
$result['data']['children']['code_id']['componentDisabled'] = $isDisabled;
$codeIdFieldConfig = [
'arguments' => [
'data' => [
'config' => [
'componentDisabled' => $isDisabled
]
]
]
];
$result['data']['children']['experiment_script'] = $experimentScriptFieldConfig;
$result['data']['children']['code_id'] = $codeIdFieldConfig;

return $result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,22 @@ public function testAfterGetMetaPositive()
$this->helper->expects($this->any())->method('isGoogleExperimentActive')->willReturn(true);
$result = $this->plugin->afterGetMeta($this->subject, []);

$this->assertArrayHasKey('experiment_script', $result['data']['children']);
$this->assertFalse($result['data']['children']['experiment_script']['componentDisabled']);
$this->assertArrayHasKey('code_id', $result['data']['children']);
$this->assertFalse($result['data']['children']['code_id']['componentDisabled']);
$children = $result['data']['children'];
$this->assertArrayHasKey('experiment_script', $children);
$this->assertFalse($children['experiment_script']['arguments']['data']['config']['componentDisabled']);
$this->assertArrayHasKey('code_id', $children);
$this->assertFalse($children['code_id']['arguments']['data']['config']['componentDisabled']);
}

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

$this->assertArrayHasKey('experiment_script', $result['data']['children']);
$this->assertTrue($result['data']['children']['experiment_script']['componentDisabled']);
$this->assertArrayHasKey('code_id', $result['data']['children']);
$this->assertTrue($result['data']['children']['code_id']['componentDisabled']);
$children = $result['data']['children'];
$this->assertArrayHasKey('experiment_script', $children);
$this->assertTrue($children['experiment_script']['arguments']['data']['config']['componentDisabled']);
$this->assertArrayHasKey('code_id', $children);
$this->assertTrue($children['code_id']['arguments']['data']['config']['componentDisabled']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ define([

_FINISH_UPDATE_INFORMATION_TRIGGER: 'finish_update_information',

_VIDEO_URL_VALIDATE_TRIGGER: 'validate_video_url',

_videoInformation: null,

_currentVideoUrl: null,
Expand All @@ -350,6 +352,23 @@ define([
this._currentVideoUrl = null;
}, this
));
this.element.on(this._VIDEO_URL_VALIDATE_TRIGGER, $.proxy(this._onUrlValidateHandler, this));
},

/**
* @private
*/
_onUrlValidateHandler: function (event, callback, forceVideo) {
var url = this.element.val(),
videoInfo;

videoInfo = this._validateURL(url, forceVideo);

if (videoInfo) {
callback();
} else {
this._onRequestError($.mage.__('Invalid video url'));
}
},

/**
Expand Down Expand Up @@ -461,7 +480,7 @@ define([
* @private
*/
function _onVimeoLoaded(data) {
var tmp = data[0],
var tmp,
respData;

if (data.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,33 +726,32 @@ define([
videoLoaded = true;

this._blockActionButtons(true);
this._videoUrlWidget.on('finish_update_information.validation', $.proxy(
function (event, status) {
videoForm.mage('validation', {

/**
* @param {jQuery} error
* @param {jQuery} element
*/
errorPlacement: function (error, element) {
error.insertAfter(element);
}
}).on('highlight.validate', function () {
$(this).validation('option');
});
videoForm.validation();

if (this._videoRequestComplete === false) {
videoLoaded = false;
this._videoUrlWidget.trigger('validate_video_url', $.proxy(function () {

videoForm.mage('validation', {

/**
* @param {jQuery} error
* @param {jQuery} element
*/
errorPlacement: function (error, element) {
error.insertAfter(element);
}
}).on('highlight.validate', function () {
$(this).validation('option');
});

callback(status && videoForm.valid() && videoLoaded);
this._videoUrlWidget.off('finish_update_information.validation');
this._blockActionButtons(false);
}, this
));
videoForm.validation();

this._videoUrlWidget.trigger('update_video_information');
if (this._videoRequestComplete === false) {
videoLoaded = false;
}

callback(videoForm.valid() && videoLoaded);
}, this));

this._blockActionButtons(false);
},

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magento_Swatches::css/swatches.css"/>
</head>
<body>
<referenceBlock name="product.info.options.configurable" remove="true"/>
<referenceBlock name="product.info.options.wrapper">
<block class="Magento\Swatches\Block\Product\Renderer\Configurable" name="product.info.options.swatches" as="swatch_options" before="-" />
</referenceBlock>
</body>
</page>
Loading

0 comments on commit c98c73d

Please sign in to comment.