Skip to content

Commit 6876182

Browse files
author
Michael Logvin
committed
Merge branch 'develop' into last_bugs
2 parents 860d417 + 8892f35 commit 6876182

File tree

39 files changed

+838
-351
lines changed

39 files changed

+838
-351
lines changed

app/code/Magento/Catalog/Api/ProductRepositoryInterface.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,4 @@ public function deleteById($sku);
7272
* @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
7373
*/
7474
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
75-
76-
/**
77-
* @param \Magento\Framework\Api\Search\SearchCriteriaInterface $searchCriteria
78-
* @return \Magento\Framework\Api\Search\SearchResultInterface
79-
*/
80-
public function search(\Magento\Framework\Api\Search\SearchCriteriaInterface $searchCriteria);
8175
}

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,14 @@ public function getAffectedFields($object)
432432

433433
return $data;
434434
}
435+
436+
/**
437+
* Get resource model instance
438+
*
439+
* @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\GroupPrice
440+
*/
441+
public function getResource()
442+
{
443+
return $this->_getResource();
444+
}
435445
}

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
135135
*/
136136
protected $extensionAttributesJoinProcessor;
137137

138-
/**
139-
* @var \Magento\Framework\Search\Request\Builder
140-
*/
141-
private $requestBuilder;
142-
143-
/**
144-
* @var \Magento\Framework\Search\SearchEngineInterface
145-
*/
146-
private $searchEngine;
147-
148-
/**
149-
* @var SearchResponseBuilder
150-
*/
151-
private $searchResponseBuilder;
152-
/**
153-
* @var \Magento\Framework\App\Config\ScopeConfigInterface
154-
*/
155-
private $scopeConfig;
156-
157138
/**
158139
* @param ProductFactory $productFactory
159140
* @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper
@@ -176,10 +157,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
176157
* @param \Magento\Eav\Model\Config $eavConfig
177158
* @param ImageProcessorInterface $imageProcessor
178159
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
179-
* @param \Magento\Framework\Search\Request\Builder $requestBuilder
180-
* @param \Magento\Framework\Search\SearchEngineInterface $searchEngine
181-
* @param SearchResponseBuilder $searchResponseBuilder
182-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
183160
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
184161
*/
185162
public function __construct(
@@ -202,11 +179,7 @@ public function __construct(
202179
ImageContentInterfaceFactory $contentFactory,
203180
MimeTypeExtensionMap $mimeTypeExtensionMap,
204181
ImageProcessorInterface $imageProcessor,
205-
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
206-
\Magento\Framework\Search\Request\Builder $requestBuilder,
207-
\Magento\Framework\Search\SearchEngineInterface $searchEngine,
208-
SearchResponseBuilder $searchResponseBuilder,
209-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
182+
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
210183
) {
211184
$this->productFactory = $productFactory;
212185
$this->collectionFactory = $collectionFactory;
@@ -228,10 +201,6 @@ public function __construct(
228201
$this->mimeTypeExtensionMap = $mimeTypeExtensionMap;
229202
$this->imageProcessor = $imageProcessor;
230203
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
231-
$this->requestBuilder = $requestBuilder;
232-
$this->searchEngine = $searchEngine;
233-
$this->searchResponseBuilder = $searchResponseBuilder;
234-
$this->scopeConfig = $scopeConfig;
235204
}
236205

237206
/**
@@ -703,45 +672,6 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
703672
return $searchResult;
704673
}
705674

706-
/**
707-
* @param \Magento\Framework\Api\Search\SearchCriteriaInterface $searchCriteria
708-
* @return \Magento\Framework\Api\Search\SearchResultInterface
709-
*/
710-
public function search(\Magento\Framework\Api\Search\SearchCriteriaInterface $searchCriteria)
711-
{
712-
$this->requestBuilder->setRequestName($searchCriteria->getRequestName());
713-
714-
$searchTerm = $searchCriteria->getSearchTerm();
715-
if (!empty($searchTerm)) {
716-
$this->requestBuilder->bind('search_term', $searchTerm);
717-
}
718-
719-
$storeId = $this->storeManager->getStore(true)->getId();
720-
$this->requestBuilder->bindDimension('scope', $storeId);
721-
722-
foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
723-
foreach ($filterGroup->getFilters() as $filter) {
724-
$this->addFieldToFilter($filter->getField(), $filter->getValue());
725-
}
726-
}
727-
728-
$priceRangeCalculation = $this->scopeConfig->getValue(
729-
\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION,
730-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
731-
);
732-
if ($priceRangeCalculation) {
733-
$this->requestBuilder->bind('price_dynamic_algorithm', $priceRangeCalculation);
734-
}
735-
736-
$this->requestBuilder->setFrom($searchCriteria->getCurrentPage() * $searchCriteria->getPageSize());
737-
$this->requestBuilder->setSize($searchCriteria->getPageSize());
738-
$request = $this->requestBuilder->create();
739-
$searchResponse = $this->searchEngine->search($request);
740-
741-
return $this->searchResponseBuilder->build($searchResponse)
742-
->setSearchCriteria($searchCriteria);
743-
}
744-
745675
/**
746676
* Helper function that adds a FilterGroup to the collection.
747677
*
@@ -762,26 +692,4 @@ protected function addFilterGroupToCollection(
762692
$collection->addFieldToFilter($fields);
763693
}
764694
}
765-
766-
/**
767-
* Apply attribute filter to facet collection
768-
*
769-
* @param string $field
770-
* @param null $condition
771-
* @return $this
772-
*/
773-
private function addFieldToFilter($field, $condition = null)
774-
{
775-
if (!is_array($condition) || !in_array(key($condition), ['from', 'to'])) {
776-
$this->requestBuilder->bind($field, $condition);
777-
} else {
778-
if (!empty($condition['from'])) {
779-
$this->requestBuilder->bind("{$field}.from", $condition['from']);
780-
}
781-
if (!empty($condition['to'])) {
782-
$this->requestBuilder->bind("{$field}.to", $condition['to']);
783-
}
784-
}
785-
return $this;
786-
}
787695
}

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,6 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase
130130
*/
131131
protected $objectManager;
132132

133-
/**
134-
* @var \Magento\Framework\Search\Request\Builder|\PHPUnit_Framework_MockObject_MockObject
135-
*/
136-
protected $requestBuilder;
137-
138-
/**
139-
* @var \Magento\Search\Model\SearchEngine|\PHPUnit_Framework_MockObject_MockObject
140-
*/
141-
protected $searchEngine;
142-
143-
/**
144-
* @var \Magento\Catalog\Model\SearchResponseBuilder|\PHPUnit_Framework_MockObject_MockObject
145-
*/
146-
protected $searchResponseBuilder;
147-
148-
/**
149-
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
150-
*/
151-
protected $scopeConfig;
152-
153133
/**
154134
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
155135
*/
@@ -241,22 +221,6 @@ protected function setUp()
241221
['getLinkTypes'], [], '', false);
242222
$this->imageProcessorMock = $this->getMock('Magento\Framework\Api\ImageProcessorInterface', [], [], '', false);
243223

244-
$this->requestBuilder = $this->getMockBuilder('Magento\Framework\Search\Request\Builder')
245-
->disableOriginalConstructor()
246-
->getMock();
247-
248-
$this->searchEngine = $this->getMockBuilder('Magento\Search\Model\SearchEngine')
249-
->disableOriginalConstructor()
250-
->getMock();
251-
252-
$this->searchResponseBuilder = $this->getMockBuilder('Magento\Catalog\Model\SearchResponseBuilder')
253-
->disableOriginalConstructor()
254-
->getMock();
255-
256-
$this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
257-
->disableOriginalConstructor()
258-
->getMockForAbstractClass();
259-
260224
$this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
261225
->disableOriginalConstructor()
262226
->getMockForAbstractClass();
@@ -280,10 +244,6 @@ protected function setUp()
280244
'mimeTypeExtensionMap' => $this->mimeTypeExtensionMapMock,
281245
'linkTypeProvider' => $this->linkTypeProviderMock,
282246
'imageProcessor' => $this->imageProcessorMock,
283-
'requestBuilder' => $this->requestBuilder,
284-
'searchEngine' => $this->searchEngine,
285-
'searchResponseBuilder' => $this->searchResponseBuilder,
286-
'scopeConfig' => $this->scopeConfig,
287247
'storeManager' => $this->storeManager,
288248
]
289249
);
@@ -1236,98 +1196,4 @@ public function testSaveExistingWithMediaGalleryEntries()
12361196
$this->model->save($this->productMock);
12371197
$this->assertEquals($expectedResult, $this->initializedProductMock->getMediaGallery('images'));
12381198
}
1239-
1240-
public function testSearch()
1241-
{
1242-
$requestName = 'requestName';
1243-
$searchTerm = 'searchTerm';
1244-
$storeId = 333;
1245-
$filterField = 'filterField';
1246-
$filterValue = 'filterValue';
1247-
$priceRangeCalculation = 'auto';
1248-
1249-
$filter = $this->getMockBuilder('Magento\Framework\Api\Filter')
1250-
->disableOriginalConstructor()
1251-
->getMock();
1252-
$filter->expects($this->once())
1253-
->method('getField')
1254-
->willReturn($filterField);
1255-
$filter->expects($this->once())
1256-
->method('getValue')
1257-
->willReturn($filterValue);
1258-
1259-
$filterGroup = $this->getMockBuilder('Magento\Framework\Api\Search\FilterGroup')
1260-
->disableOriginalConstructor()
1261-
->getMock();
1262-
$filterGroup->expects($this->once())
1263-
->method('getFilters')
1264-
->willReturn([$filter]);
1265-
1266-
$searchCriteria = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaInterface')
1267-
->disableOriginalConstructor()
1268-
->getMockForAbstractClass();
1269-
$searchCriteria->expects($this->once())
1270-
->method('getRequestName')
1271-
->willReturn($requestName);
1272-
$searchCriteria->expects($this->once())
1273-
->method('getSearchTerm')
1274-
->willReturn($searchTerm);
1275-
$searchCriteria->expects($this->once())
1276-
->method('getFilterGroups')
1277-
->willReturn([$filterGroup]);
1278-
1279-
$store = $this->getMockBuilder('Magento\Store\Model\Store')
1280-
->disableOriginalConstructor()
1281-
->getMock();
1282-
$store->expects($this->once())
1283-
->method('getId')
1284-
->willReturn($storeId);
1285-
1286-
$searchResult = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResult')
1287-
->disableOriginalConstructor()
1288-
->getMockForAbstractClass();
1289-
1290-
$request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface')
1291-
->disableOriginalConstructor()
1292-
->getMockForAbstractClass();
1293-
1294-
$response = $this->getMockBuilder('Magento\Framework\Search\ResponseInterface')
1295-
->disableOriginalConstructor()
1296-
->getMockForAbstractClass();
1297-
1298-
$this->requestBuilder->expects($this->once())
1299-
->method('setRequestName')
1300-
->with($requestName);
1301-
$this->requestBuilder->expects($this->once())
1302-
->method('bindDimension')
1303-
->with('scope', $storeId);
1304-
$this->requestBuilder->expects($this->any())
1305-
->method('bind');;
1306-
$this->requestBuilder->expects($this->once())
1307-
->method('create')
1308-
->willReturn($request);
1309-
1310-
$this->searchEngine->expects($this->once())
1311-
->method('search')
1312-
->with($request)
1313-
->willReturn($response);
1314-
1315-
$this->searchResponseBuilder->expects($this->once())
1316-
->method('build')
1317-
->with($response)
1318-
->willReturn($searchResult);
1319-
1320-
$this->storeManager->expects($this->once())
1321-
->method('getStore')
1322-
->willReturn($store);
1323-
1324-
$this->scopeConfig->expects($this->once())
1325-
->method('getValue')
1326-
->with(AlgorithmFactory::XML_PATH_RANGE_CALCULATION, ScopeInterface::SCOPE_STORE)
1327-
->willReturn($priceRangeCalculation);
1328-
1329-
$searchResult = $this->model->search($searchCriteria);
1330-
1331-
$this->assertInstanceOf('Magento\Framework\Api\Search\SearchResultInterface', $searchResult);
1332-
}
13331199
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
<resource ref="anonymous" />
4040
</resources>
4141
</route>
42-
<route url="/V1/products/search" method="GET">
43-
<service class="Magento\Catalog\Api\ProductRepositoryInterface" method="search"/>
44-
<resources>
45-
<resource ref="anonymous" />
46-
</resources>
47-
</route>
4842

4943
<route url="/V1/products/attributes/types" method="GET">
5044
<service class="Magento\Catalog\Api\ProductAttributeTypesListInterface" method="getItems"/>

app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,17 @@ protected function getRuleProductsStmt($websiteId, $productId = null)
612612
$select->where('rp.product_id=?', $productId);
613613
}
614614

615+
/**
616+
* Join group price to result
617+
*/
618+
$groupPriceAttr = $this->eavConfig->getAttribute(Product::ENTITY, 'group_price');
619+
$select->joinLeft(
620+
['gp' => $groupPriceAttr->getBackend()->getResource()->getMainTable()],
621+
'gp.entity_id=rp.product_id AND gp.customer_group_id=rp.customer_group_id AND '
622+
. $this->getReadAdapter()->getCheckSql('gp.website_id=0', 'TRUE', 'gp.website_id=rp.website_id'),
623+
'value'
624+
);
625+
615626
/**
616627
* Join default price and websites prices to result
617628
*/
@@ -653,7 +664,10 @@ protected function getRuleProductsStmt($websiteId, $productId = null)
653664
[]
654665
);
655666
$select->columns([
656-
'default_price' => $this->getReadAdapter()->getIfNullSql($tableAlias . '.value', 'pp_default.value'),
667+
'default_price' => $this->getReadAdapter()->getIfNullSql(
668+
'gp.value',
669+
$this->getReadAdapter()->getIfNullSql($tableAlias . '.value', 'pp_default.value')
670+
),
657671
]);
658672

659673
return $read->query($select);

0 commit comments

Comments
 (0)