Skip to content

Commit 9fd1510

Browse files
committed
MAGETWO-55620: Merge branch '2.1' of github.com:magento/magento2ce into MAGETWO-55620
2 parents c478ec2 + f599a3b commit 9fd1510

File tree

7 files changed

+90
-11
lines changed

7 files changed

+90
-11
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function addMediaDataToProduct(Product $product, array $mediaEntries)
7878

7979
foreach ($mediaEntries as $mediaEntry) {
8080
$mediaEntry = $this->substituteNullsWithDefaultValues($mediaEntry);
81-
$value['images'][] = $mediaEntry;
81+
$value['images'][$mediaEntry['value_id']] = $mediaEntry;
8282
}
8383
$product->setData($attrCode, $value);
8484
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ public function __construct(
5656
public function build($productId)
5757
{
5858
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
59+
$productTable = $this->resource->getTableName('catalog_product_entity');
5960

6061
return [$this->resource->getConnection()->select()
61-
->from(['parent' => 'catalog_product_entity'], '')
62+
->from(['parent' => $productTable], '')
6263
->joinInner(
6364
['link' => $this->resource->getTableName('catalog_product_relation')],
6465
"link.parent_id = parent.$linkField",
6566
[]
6667
)->joinInner(
67-
['child' => 'catalog_product_entity'],
68+
['child' => $productTable],
6869
"child.entity_id = link.child_id",
6970
['entity_id']
7071
)->joinInner(

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ public function build($productId)
6565
{
6666
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
6767
$priceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
68+
$productTable = $this->resource->getTableName('catalog_product_entity');
69+
6870
$priceSelect = $this->resource->getConnection()->select()
69-
->from(['parent' => 'catalog_product_entity'], '')
71+
->from(['parent' => $productTable], '')
7072
->joinInner(
7173
['link' => $this->resource->getTableName('catalog_product_relation')],
7274
"link.parent_id = parent.$linkField",
7375
[]
7476
)->joinInner(
75-
['child' => 'catalog_product_entity'],
77+
['child' => $productTable],
7678
"child.entity_id = link.child_id",
7779
['entity_id']
7880
)->joinInner(

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,16 @@ public function build($productId)
8686
$specialPriceToDate = $this->eavConfig->getAttribute(Product::ENTITY, 'special_to_date');
8787
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
8888
$currentDate = $this->dateTime->formatDate($timestamp, false);
89+
$productTable = $this->resource->getTableName('catalog_product_entity');
8990

9091
$specialPrice = $this->resource->getConnection()->select()
91-
->from(['parent' => 'catalog_product_entity'], '')
92+
->from(['parent' => $productTable], '')
9293
->joinInner(
9394
['link' => $this->resource->getTableName('catalog_product_relation')],
9495
"link.parent_id = parent.$linkField",
9596
[]
9697
)->joinInner(
97-
['child' => 'catalog_product_entity'],
98+
['child' => $productTable],
9899
"child.entity_id = link.child_id",
99100
['entity_id']
100101
)->joinInner(

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ public function __construct(
6868
public function build($productId)
6969
{
7070
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
71+
$productTable = $this->resource->getTableName('catalog_product_entity');
72+
7173
$priceSelect = $this->resource->getConnection()->select()
72-
->from(['parent' => 'catalog_product_entity'], '')
74+
->from(['parent' => $productTable], '')
7375
->joinInner(
7476
['link' => $this->resource->getTableName('catalog_product_relation')],
7577
"link.parent_id = parent.$linkField",
7678
[]
7779
)->joinInner(
78-
['child' => 'catalog_product_entity'],
80+
['child' => $productTable],
7981
"child.entity_id = link.child_id",
8082
['entity_id']
8183
)->joinInner(
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\Unit\Model\Product\Gallery;
7+
8+
/**
9+
* Unit test for catalog product Media Gallery ReadHandler
10+
*/
11+
class ReadHandlerTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/** @var \Magento\Catalog\Model\Product\Gallery\ReadHandler */
14+
protected $model;
15+
16+
/**
17+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
18+
*/
19+
protected $objectHelper;
20+
21+
/**
22+
* @var \Magento\Catalog\Model\Product\Attribute\Repository|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
protected $attributeRepository;
25+
26+
protected function setUp()
27+
{
28+
$this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
29+
30+
$this->attributeRepository = $this->getMock(
31+
'Magento\Catalog\Model\Product\Attribute\Repository',
32+
['get'],
33+
[],
34+
'',
35+
false
36+
);
37+
$this->model = $this->objectHelper->getObject(
38+
\Magento\Catalog\Model\Product\Gallery\ReadHandler::class,
39+
[
40+
'attributeRepository' => $this->attributeRepository,
41+
]
42+
);
43+
}
44+
45+
public function testAddMediaDataToProduct()
46+
{
47+
$attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
48+
->disableOriginalConstructor()
49+
->getMock();
50+
51+
$attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue('image'));
52+
53+
$this->attributeRepository->expects($this->once())
54+
->method('get')
55+
->with('media_gallery')
56+
->willReturn($attribute);
57+
58+
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
59+
->disableOriginalConstructor()
60+
->getMock();
61+
$product->expects($this->once())->method('setData')->with(
62+
'image',
63+
[
64+
'images' =>[
65+
10 => ['value_id' => 10,]
66+
],
67+
'values' => []
68+
]
69+
);
70+
$this->model->addMediaDataToProduct($product, [['value_id' => 10]]);
71+
}
72+
}

app/code/Magento/CatalogRule/Model/ResourceModel/Product/LinkedProductSelectBuilderByCatalogRulePrice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,16 @@ public function build($productId)
7474
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
7575
$currentDate = $this->dateTime->formatDate($timestamp, false);
7676
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
77+
$productTable = $this->resource->getTableName('catalog_product_entity');
7778

7879
return [$this->resource->getConnection()->select()
79-
->from(['parent' => 'catalog_product_entity'], '')
80+
->from(['parent' => $productTable], '')
8081
->joinInner(
8182
['link' => $this->resource->getTableName('catalog_product_relation')],
8283
"link.parent_id = parent.$linkField",
8384
[]
8485
)->joinInner(
85-
['child' => 'catalog_product_entity'],
86+
['child' => $productTable],
8687
"child.entity_id = link.child_id",
8788
['entity_id']
8889
)->joinInner(

0 commit comments

Comments
 (0)