Skip to content

Commit c3c0393

Browse files
author
cspruiell
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-61509-Schema-Comparison
2 parents 743e4fb + 62667cb commit c3c0393

File tree

79 files changed

+2852
-1043
lines changed

Some content is hidden

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

79 files changed

+2852
-1043
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor;
7+
8+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
9+
use Magento\Framework\Api\Filter;
10+
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface;
11+
use Magento\Framework\Data\Collection\AbstractDb;
12+
13+
class ProductStoreFilter implements CustomFilterInterface
14+
{
15+
/**
16+
* Apply store Filter to Product Collection
17+
*
18+
* @param Filter $filter
19+
* @param AbstractDb $collection
20+
* @return bool Whether the filter is applied
21+
*/
22+
public function apply(Filter $filter, AbstractDb $collection)
23+
{
24+
/** @var Collection $collection */
25+
$collection->addStoreFilter($filter->getValue());
26+
return true;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor;
7+
8+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
9+
use Magento\Framework\Api\Filter;
10+
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface;
11+
use Magento\Framework\Data\Collection\AbstractDb;
12+
13+
class ProductWebsiteFilter implements CustomFilterInterface
14+
{
15+
/**
16+
* Apply website Filter to Product Collection
17+
*
18+
* @param Filter $filter
19+
* @param AbstractDb $collection
20+
* @return bool Whether the filter is applied
21+
*/
22+
public function apply(Filter $filter, AbstractDb $collection)
23+
{
24+
$value = $filter->getValue();
25+
if (strpos($value, ',') !== false) {
26+
$value = explode(',', $value);
27+
}
28+
/** @var Collection $collection */
29+
$collection->addWebsiteFilter($value);
30+
return true;
31+
}
32+
}

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ public function copy(\Magento\Catalog\Model\Product $product)
5454
$product->getWebsiteIds();
5555
$product->getCategoryIds();
5656

57+
/** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */
58+
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
59+
5760
/** @var \Magento\Catalog\Model\Product $duplicate */
5861
$duplicate = $this->productFactory->create();
5962
$duplicate->setData($product->getData());
6063
$duplicate->setOptions([]);
6164
$duplicate->setIsDuplicate(true);
62-
$duplicate->setOriginalId($product->getEntityId());
65+
$duplicate->setOriginalLinkId($product->getData($metadata->getLinkField()));
6366
$duplicate->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);
6467
$duplicate->setCreatedAt(null);
6568
$duplicate->setUpdatedAt(null);
@@ -81,7 +84,6 @@ public function copy(\Magento\Catalog\Model\Product $product)
8184
}
8285
} while (!$isDuplicateSaved);
8386
$this->getOptionRepository()->duplicate($product, $duplicate);
84-
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
8587
$product->getResource()->duplicate(
8688
$product->getData($metadata->getLinkField()),
8789
$duplicate->getData($metadata->getLinkField())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ protected function duplicate($product)
297297
$this->resourceModel->duplicate(
298298
$this->getAttribute()->getAttributeId(),
299299
isset($mediaGalleryData['duplicate']) ? $mediaGalleryData['duplicate'] : [],
300-
$product->getOriginalId(),
300+
$product->getOriginalLinkId(),
301301
$product->getData($this->metadata->getLinkField())
302302
);
303303

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

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,55 +1841,12 @@ protected function _productLimitationJoinStore()
18411841
$this->getSelect()->columns('visibility', 'cat_index');
18421842
}
18431843

1844-
$fromPart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::FROM);
1845-
if (!isset($fromPart['store_index'])) {
1846-
$this->getSelect()->joinLeft(
1847-
['store_index' => $this->getTable('store')],
1848-
'store_index.store_id = ' . $filters['store_table'] . '.store_id',
1849-
[]
1850-
);
1851-
}
1852-
if (!isset($fromPart['store_group_index'])) {
1853-
$this->getSelect()->joinLeft(
1854-
['store_group_index' => $this->getTable('store_group')],
1855-
'store_index.group_id = store_group_index.group_id',
1856-
[]
1857-
);
1858-
}
1859-
if (!isset($fromPart['store_cat_index'])) {
1860-
$this->getSelect()->joinLeft(
1861-
['store_cat_index' => $this->categoryProductIndexerFrontend->getMainTable()],
1862-
join(
1863-
' AND ',
1864-
[
1865-
'store_cat_index.product_id = e.entity_id',
1866-
'store_cat_index.store_id = ' . $filters['store_table'] . '.store_id',
1867-
'store_cat_index.category_id=store_group_index.root_category_id'
1868-
]
1869-
),
1870-
['store_visibility' => 'visibility']
1871-
);
1872-
}
18731844
// Avoid column duplication problems
18741845
$this->_resourceHelper->prepareColumnsList($this->getSelect());
18751846

1876-
$whereCond = join(
1877-
' OR ',
1878-
[
1879-
$this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']),
1880-
$this->getConnection()->quoteInto('store_cat_index.visibility IN(?)', $filters['visibility'])
1881-
]
1882-
);
1883-
1847+
$whereCond = $this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']);
18841848
$wherePart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::WHERE);
1885-
$hasCond = false;
1886-
foreach ($wherePart as $cond) {
1887-
if ($cond == '(' . $whereCond . ')') {
1888-
$hasCond = true;
1889-
}
1890-
}
1891-
1892-
if (!$hasCond) {
1849+
if (array_search('(' . $whereCond . ')', $wherePart) === false) {
18931850
$this->getSelect()->where($whereCond);
18941851
}
18951852

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\Unit\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor;
7+
8+
use Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductWebsiteFilter;
9+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
10+
use Magento\Framework\Api\Filter;
11+
12+
class ProductWebsiteFilterTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/** @var ProductWebsiteFilter */
15+
private $model;
16+
17+
protected function setUp()
18+
{
19+
$this->model = new ProductWebsiteFilter();
20+
}
21+
22+
public function testApply()
23+
{
24+
/** @var Filter|\PHPUnit_Framework_MockObject_MockObject $filterMock */
25+
$filterMock = $this->getMockBuilder(Filter::class)
26+
->disableOriginalConstructor()
27+
->getMock();
28+
29+
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
30+
$collectionMock = $this->getMockBuilder(Collection::class)
31+
->disableOriginalConstructor()
32+
->getMock();
33+
34+
$filterMock->expects($this->once())
35+
->method('getValue')
36+
->willReturn('1,2');
37+
38+
$collectionMock->expects($this->once())
39+
->method('addWebsiteFilter')
40+
->with(['1', '2']);
41+
42+
$this->assertTrue($this->model->apply($filterMock, $collectionMock));
43+
}
44+
}

app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testCopy()
9898
'setOptions',
9999
'getData',
100100
'setIsDuplicate',
101-
'setOriginalId',
101+
'setOriginalLinkId',
102102
'setStatus',
103103
'setCreatedAt',
104104
'setUpdatedAt',
@@ -117,7 +117,7 @@ public function testCopy()
117117

118118
$duplicateMock->expects($this->once())->method('setOptions')->with([]);
119119
$duplicateMock->expects($this->once())->method('setIsDuplicate')->with(true);
120-
$duplicateMock->expects($this->once())->method('setOriginalId')->with(1);
120+
$duplicateMock->expects($this->once())->method('setOriginalLinkId')->with(1);
121121
$duplicateMock->expects(
122122
$this->once()
123123
)->method(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@
835835
<arguments>
836836
<argument name="customFilters" xsi:type="array">
837837
<item name="category_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductCategoryFilter</item>
838+
<item name="store" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductStoreFilter</item>
839+
<item name="website_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductWebsiteFilter</item>
838840
</argument>
839841
</arguments>
840842
</virtualType>

app/code/Magento/Checkout/view/frontend/web/js/action/redirect-on-success.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
*/
99
define(
1010
[
11-
'mage/url'
11+
'mage/url',
12+
'Magento_Checkout/js/model/full-screen-loader'
1213
],
13-
function (url) {
14+
function (url, fullScreenLoader) {
1415
'use strict';
1516

1617
return {
@@ -20,6 +21,7 @@ define(
2021
* Provide redirect to page
2122
*/
2223
execute: function () {
24+
fullScreenLoader.startLoader();
2325
window.location.replace(url.build(this.redirectUrl));
2426
}
2527
};

app/code/Magento/Deploy/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "N/A",
44
"require": {
55
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
6-
"magento/framework": "100.*.*",
6+
"magento/framework": "100.2.*",
77
"magento/module-store": "100.2.*",
88
"magento/module-require-js": "100.2.*",
99
"magento/module-user": "100.2.*",

0 commit comments

Comments
 (0)