Skip to content

Commit

Permalink
Merge branch '2.1-develop' into FearlessKiwis-MAGETWO-59284-New
Browse files Browse the repository at this point in the history
  • Loading branch information
abarua17 committed Oct 18, 2016
2 parents 6d57a2e + 606b04d commit 5a20ba7
Show file tree
Hide file tree
Showing 356 changed files with 16,149 additions and 1,914 deletions.
1 change: 0 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ return Symfony\CS\Config\Config::create()
'extra_empty_lines',
'include',
'join_function',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'new_with_braces',
'object_operator',
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<resource>Magento_Config::config_general</resource>
<group id="country" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Country Options</label>
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
<label>Allow Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Braintree/Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,14 @@ public function isActive()
{
return (bool) $this->getValue(self::KEY_ACTIVE);
}

/**
* Get Merchant account ID
*
* @return string
*/
public function getMerchantAccountId()
{
return $this->getValue(self::KEY_MERCHANT_ACCOUNT_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function build(array $buildSubject)
self::ORDER_ID => $order->getOrderIncrementId()
];

$merchantAccountId = $this->config->getValue(Config::KEY_MERCHANT_ACCOUNT_ID);
$merchantAccountId = $this->config->getMerchantAccountId();
if (!empty($merchantAccountId)) {
$result[self::MERCHANT_ACCOUNT_ID] = $merchantAccountId;
}
Expand Down
10 changes: 9 additions & 1 deletion app/code/Magento/Braintree/Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Braintree\Model\Ui;

use Magento\Braintree\Gateway\Request\PaymentDataBuilder;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Braintree\Gateway\Config\Config;
use Magento\Braintree\Gateway\Config\PayPal\Config as PayPalConfig;
Expand Down Expand Up @@ -116,7 +117,14 @@ public function getConfig()
public function getClientToken()
{
if (empty($this->clientToken)) {
$this->clientToken = $this->adapter->generate();
$params = [];

$merchantAccountId = $this->config->getMerchantAccountId();
if (!empty($merchantAccountId)) {
$params[PaymentDataBuilder::MERCHANT_ACCOUNT_ID] = $merchantAccountId;
}

$this->clientToken = $this->adapter->generate($params);
}

return $this->clientToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public function testBuild()
->willReturnMap($additionalData);

$this->configMock->expects(static::once())
->method('getValue')
->with(Config::KEY_MERCHANT_ACCOUNT_ID)
->method('getMerchantAccountId')
->willReturn(self::MERCHANT_ACCOUNT_ID);

$this->paymentDO->expects(static::once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
class ConfigProviderTest extends \PHPUnit_Framework_TestCase
{
const SDK_URL = 'https://js.braintreegateway.com/v2/braintree.js';

const CLIENT_TOKEN = 'token';
const MERCHANT_ACCOUNT_ID = '245345';

/**
* @var Config|\PHPUnit_Framework_MockObject_MockObject
Expand Down Expand Up @@ -115,11 +115,17 @@ public function testGetConfig($config, $expected)

/**
* @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken
* @dataProvider getClientTokenDataProvider
*/
public function testGetClientToken()
public function testGetClientToken($merchantAccountId, $params)
{
$this->config->expects(static::once())
->method('getMerchantAccountId')
->willReturn($merchantAccountId);

$this->braintreeAdapter->expects(static::once())
->method('generate')
->with($params)
->willReturn(self::CLIENT_TOKEN);

static::assertEquals(self::CLIENT_TOKEN, $this->configProvider->getClientToken());
Expand Down Expand Up @@ -188,4 +194,21 @@ public function getConfigDataProvider()
]
];
}

/**
* @return array
*/
public function getClientTokenDataProvider()
{
return [
[
'merchantAccountId' => '',
'params' => []
],
[
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
'params' => ['merchantAccountId' => self::MERCHANT_ACCOUNT_ID]
]
];
}
}
43 changes: 30 additions & 13 deletions app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,7 @@ private function getShipmentTypeValue($type)
protected function cleanNotBundleAdditionalAttributes($dataRow)
{
if (!empty($dataRow['additional_attributes'])) {
$additionalAttributes = explode(
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
$dataRow['additional_attributes']
);
$additionalAttributes = $this->parseAdditionalAttributes($dataRow['additional_attributes']);
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
}

Expand All @@ -349,17 +346,37 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
*/
protected function getNotBundleAttributes($additionalAttributes)
{
$cleanedAdditionalAttributes = '';
foreach ($additionalAttributes as $attribute) {
list($attributeCode, $attributeValue) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attribute);
if (!in_array('bundle_' . $attributeCode, $this->getBundleColumns())) {
$cleanedAdditionalAttributes .= $attributeCode
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $attributeValue
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
$filteredAttributes = [];
foreach ($additionalAttributes as $code => $value) {
if (!in_array('bundle_' . $code, $this->getBundleColumns())) {
$filteredAttributes[] = $code . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
}
}
return implode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $filteredAttributes);
}

return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
/**
* Retrieves additional attributes as array code=>value
*
* @param string $additionalAttributes
* @return array
*/
private function parseAdditionalAttributes($additionalAttributes)
{
$attributeNameValuePairs = explode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
$preparedAttributes = [];
$code = '';
foreach ($attributeNameValuePairs as $attributeData) {
if (strpos($attributeData, ImportProductModel::PAIR_NAME_VALUE_SEPARATOR) === false) {
if (!$code) {
continue;
}
$preparedAttributes[$code] .= ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . $attributeData;
continue;
}
list($code, $value) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
$preparedAttributes[$code] = $value;
}
return $preparedAttributes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ public function testAddHeaderColumns()
public function testAddData()
{
$preparedData = $this->rowCustomizerMock->prepareData($this->productResourceCollection, [1]);
$attributes = 'attribute=1,sku_type=1,price_type=1,price_view=1,weight_type=1,values=values,shipment_type=1';
$attributes = 'attribute=1,sku_type=1,attribute2="Text",price_type=1,price_view=1,weight_type=1,'
. 'values=values,shipment_type=1,attribute3=One,Two,Three';
$dataRow = [
'sku' => 'sku1',
'additional_attributes' => $attributes
];
$preparedRow = $preparedData->addData($dataRow, 1);
$expected = [
'sku' => 'sku1',
'additional_attributes' => 'attribute=1',
'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three',
'bundle_price_type' => 'fixed',
'bundle_shipment_type' => 'separately',
'bundle_sku_type' => 'fixed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class InvalidateVarnishObserver implements ObserverInterface
*/
protected $purgeCache;

/**
* Invalidation tags resolver
*
* @var \Magento\Framework\App\Cache\Tag\Resolver
*/
private $tagResolver;

/**
* @param \Magento\PageCache\Model\Config $config
* @param \Magento\CacheInvalidate\Model\PurgeCache $purgeCache
Expand All @@ -42,18 +49,35 @@ public function __construct(
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$object = $observer->getEvent()->getObject();
if (!is_object($object)) {
return;
}
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled()) {
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
$tags = [];
$pattern = "((^|,)%s(,|$))";
foreach ($object->getIdentities() as $tag) {
$tags[] = sprintf($pattern, $tag);
}
if (!empty($tags)) {
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
}
$bareTags = $this->getTagResolver()->getTags($object);

$tags = [];
$pattern = "((^|,)%s(,|$))";
foreach ($bareTags as $tag) {
$tags[] = sprintf($pattern, $tag);
}
if (!empty($tags)) {
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
}

}
}

/**
* @deprecated
* @return \Magento\Framework\App\Cache\Tag\Resolver
*/
private function getTagResolver()
{
if ($this->tagResolver === null) {
$this->tagResolver = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\App\Cache\Tag\Resolver::class);
}
return $this->tagResolver;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\CacheInvalidate\Test\Unit\Observer;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;

class InvalidateVarnishObserverTest extends \PHPUnit_Framework_TestCase
{
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\CacheInvalidate\Observer\InvalidateVarnishObserver */
Expand All @@ -22,11 +24,16 @@ class InvalidateVarnishObserverTest extends \PHPUnit_Framework_TestCase
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\DataObject\ */
protected $observerObject;

/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Cache\Tag\Resolver */
private $tagResolver;

/**
* Set up all mocks and data for test
*/
protected function setUp()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

$this->configMock = $this->getMock(
'Magento\PageCache\Model\Config',
['getType', 'isEnabled'],
Expand All @@ -39,6 +46,10 @@ protected function setUp()
$this->configMock,
$this->purgeCache
);

$this->tagResolver = $this->getMock(\Magento\Framework\App\Cache\Tag\Resolver::class, [], [], '', false);
$helper->setBackwardCompatibleProperty($this->model, 'tagResolver', $this->tagResolver);

$this->observerMock = $this->getMock(
'Magento\Framework\Event\Observer',
['getEvent'],
Expand Down Expand Up @@ -68,7 +79,7 @@ public function testInvalidateVarnish()
$eventMock = $this->getMock('Magento\Framework\Event', ['getObject'], [], '', false);
$eventMock->expects($this->once())->method('getObject')->will($this->returnValue($this->observerObject));
$this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
$this->observerObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags));
$this->tagResolver->expects($this->once())->method('getTags')->will($this->returnValue($tags));
$this->purgeCache->expects($this->once())->method('sendPurgeRequest')->with($pattern);

$this->model->execute($this->observerMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ define(
},
initialize: function() {
this._super();
captchaConfig = window[this.configSource]['captcha'];

if (captchaConfig) {
if (window[this.configSource] && window[this.configSource]['captcha']) {
captchaConfig = window[this.configSource]['captcha'];
$.each(captchaConfig, function(formId, captchaData) {
captchaData.formId = formId;
captchaList.add(Captcha(captchaData));
Expand Down
5 changes: 3 additions & 2 deletions app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ protected function _getStore()
*/
protected function _prepareCollection()
{
parent::_prepareCollection();

$store = $this->_getStore();
$collection = $this->_productFactory->create()->getCollection()->addAttributeToSelect(
'sku'
Expand Down Expand Up @@ -184,6 +182,9 @@ protected function _prepareCollection()
$this->setCollection($collection);

$this->getCollection()->addWebsiteNamesToResult();

parent::_prepareCollection();

return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function execute()
$attributesData[$attributeCode] = $value;
} elseif ($attribute->getFrontendInput() == 'multiselect') {
// Check if 'Change' checkbox has been checked by admin for this attribute
$isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox');
$isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode);
if (!$isChanged) {
unset($attributesData[$attributeCode]);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
{
/**
* Whether to use main or temporary index table
*
* @var bool
*/
protected $useTempTable = false;

/**
* Refresh entities index
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ protected function _generateUniqueSku($object)
{
$attribute = $this->getAttribute();
$entity = $attribute->getEntity();
$increment = $this->_getLastSimilarAttributeValueIncrement($attribute, $object);
$attributeValue = $object->getData($attribute->getAttributeCode());
$increment = null;
while (!$entity->checkAttributeUniqueValue($attribute, $object)) {
if ($increment === null) {
$increment = $this->_getLastSimilarAttributeValueIncrement($attribute, $object);
}
$sku = trim($attributeValue);
if (strlen($sku . '-' . ++$increment) > self::SKU_MAX_LENGTH) {
$sku = substr($sku, 0, -strlen($increment) - 1);
Expand Down
Loading

0 comments on commit 5a20ba7

Please sign in to comment.