Skip to content

Commit f03f69e

Browse files
authored
Merge a4b34fe into MAGETWO-66180
2 parents 929bc66 + a4b34fe commit f03f69e

File tree

52 files changed

+1941
-175
lines changed

Some content is hidden

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

52 files changed

+1941
-175
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*
1414
* @method \Magento\Backend\Block\Menu setAdditionalCacheKeyInfo(array $cacheKeyInfo)
1515
* @method array getAdditionalCacheKeyInfo()
16+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1617
*/
1718
class Menu extends \Magento\Backend\Block\Template
1819
{
@@ -381,7 +382,7 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
381382
$itemName = substr($menuId, strrpos($menuId, '::') + 2);
382383
$itemClass = str_replace('_', '-', strtolower($itemName));
383384

384-
if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake']) {
385+
if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake'] && $itemPosition != 1) {
385386
$output .= '</ul></li><li class="column"><ul role="menu">';
386387
}
387388

app/code/Magento/Bundle/view/base/templates/product/price/final_price.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<?php
1212
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
1313
/** @var \Magento\Bundle\Pricing\Render\FinalPriceBox $block */
14-
$productId = $block->getSaleableItem()->getId();
14+
15+
1516
/** @var \Magento\Bundle\Pricing\Price\FinalPrice $finalPriceModel */
1617
$finalPriceModel = $block->getPrice();
1718
$minimalPrice = $finalPriceModel->getMinimalPrice();

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
863863
* Filter Product by Categories
864864
*
865865
* @param array $categoriesFilter
866+
* @return $this
866867
*/
867868
public function addCategoriesFilter(array $categoriesFilter)
868869
{
@@ -876,6 +877,7 @@ public function addCategoriesFilter(array $categoriesFilter)
876877
];
877878
$this->getSelect()->where($this->getConnection()->prepareSqlCondition('e.entity_id' , $selectCondition));
878879
}
880+
return $this;
879881
}
880882

881883
/**
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Eav\Model\Entity\Attribute\Backend;
7+
8+
use Magento\Framework\Serialize\Serializer\Json;
9+
10+
/**
11+
* Backend model for attribute that stores structures in json format
12+
*/
13+
class JsonEncoded extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
14+
{
15+
/**
16+
* @var Json
17+
*/
18+
private $jsonSerializer;
19+
20+
/**
21+
* ArrayBackend constructor.
22+
*
23+
* @param Json $jsonSerializer
24+
*/
25+
public function __construct(Json $jsonSerializer)
26+
{
27+
$this->jsonSerializer = $jsonSerializer;
28+
}
29+
30+
/**
31+
* Encode before saving
32+
*
33+
* @param \Magento\Framework\DataObject $object
34+
* @return $this
35+
*/
36+
public function beforeSave($object)
37+
{
38+
// parent::beforeSave() is not called intentionally
39+
$attrCode = $this->getAttribute()->getAttributeCode();
40+
if ($object->hasData($attrCode)) {
41+
$object->setData($attrCode, $this->jsonSerializer->serialize($object->getData($attrCode)));
42+
}
43+
return $this;
44+
}
45+
46+
/**
47+
* Decode after loading
48+
*
49+
* @param \Magento\Framework\DataObject $object
50+
* @return $this
51+
*/
52+
public function afterLoad($object)
53+
{
54+
parent::afterLoad($object);
55+
$attrCode = $this->getAttribute()->getAttributeCode();
56+
$object->setData($attrCode, $this->jsonSerializer->unserialize($object->getData($attrCode)));
57+
return $this;
58+
}
59+
}

app/code/Magento/Eav/Model/Entity/Attribute/Backend/Serialized.php

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Backend;
8+
9+
use Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded;
10+
11+
class JsonEncodedTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded
15+
*/
16+
private $model;
17+
18+
/**
19+
* @var \Magento\Eav\Model\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $attributeMock;
22+
23+
/**
24+
* @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $serializerMock;
27+
28+
/**
29+
* Set up before test
30+
*/
31+
protected function setUp()
32+
{
33+
$this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
34+
->disableOriginalConstructor()
35+
->setMethods(['serialize', 'unserialize'])
36+
->getMock();
37+
38+
$this->serializerMock->expects($this->any())
39+
->method('serialize')
40+
->will(
41+
$this->returnCallback(
42+
function ($value) {
43+
return json_encode($value);
44+
}
45+
)
46+
);
47+
48+
$this->serializerMock->expects($this->any())
49+
->method('unserialize')
50+
->will(
51+
$this->returnCallback(
52+
function ($value) {
53+
return json_decode($value, true);
54+
}
55+
)
56+
);
57+
58+
$this->attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
59+
->disableOriginalConstructor()
60+
->setMethods(['getAttributeCode'])
61+
->getMock();
62+
63+
$this->attributeMock->expects($this->any())
64+
->method('getAttributeCode')
65+
->will($this->returnValue('json_encoded'));
66+
67+
$this->model = new JsonEncoded($this->serializerMock);
68+
$this->model->setAttribute($this->attributeMock);
69+
}
70+
71+
/**
72+
* Test before save handler
73+
*/
74+
public function testBeforeSave()
75+
{
76+
$product = new \Magento\Framework\DataObject(
77+
[
78+
'json_encoded' => [1, 2, 3]
79+
]
80+
);
81+
$this->model->beforeSave($product);
82+
$this->assertEquals(json_encode([1, 2, 3]), $product->getData('json_encoded'));
83+
}
84+
85+
/**
86+
* Test after load handler
87+
*/
88+
public function testAfterLoad()
89+
{
90+
$product = new \Magento\Framework\DataObject(
91+
[
92+
'json_encoded' => json_encode([1, 2, 3])
93+
]
94+
);
95+
$this->model->afterLoad($product);
96+
$this->assertEquals([1, 2, 3], $product->getData('json_encoded'));
97+
}
98+
}

app/code/Magento/Integration/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function mapResources(array $resources)
2121
foreach ($resources as $resource) {
2222
$item = [];
2323
$item['attr']['data-id'] = $resource['id'];
24-
$item['data'] = $resource['title'];
24+
$item['data'] = __($resource['title']);
2525
$item['children'] = [];
2626
if (isset($resource['children'])) {
2727
$item['state'] = 'open';

app/code/Magento/Rule/Model/Condition/AbstractCondition.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ public function getValueName()
441441
}
442442
if (!empty($valueArr)) {
443443
$value = implode(', ', $valueArr);
444+
} elseif (is_array($value)) {
445+
$value = implode(', ', $value);
444446
}
445447
return $value;
446448
}

0 commit comments

Comments
 (0)