Skip to content

Commit 21b0d36

Browse files
committed
Merge branch 'develop' of https://github.corp.ebay.com/magento2/magento2ce into MAGETWO-40006
2 parents 6e4e299 + ec6d4e6 commit 21b0d36

File tree

42 files changed

+324
-305
lines changed

Some content is hidden

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

42 files changed

+324
-305
lines changed

app/code/Magento/Catalog/Helper/Product/Composite.php

+1-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Catalog\Helper\Product;
1313
use Magento\Store\Model\StoreManagerInterface;
1414
use Magento\Customer\Controller\RegistryConstants;
15-
use Magento\Customer\Api\CustomerRepositoryInterface;
1615
use Magento\Framework\Registry;
1716

1817
/**
@@ -52,35 +51,27 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper
5251
*/
5352
protected $productRepository;
5453

55-
/**
56-
* @var CustomerRepositoryInterface
57-
*/
58-
protected $customerRepository;
59-
6054
/**
6155
* @param \Magento\Framework\App\Helper\Context $context
6256
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
6357
* @param Product $catalogProduct
6458
* @param Registry $coreRegistry
6559
* @param LayoutFactory $resultLayoutFactory
6660
* @param ProductRepositoryInterface $productRepository
67-
* @param CustomerRepositoryInterface $customerRepository
6861
*/
6962
public function __construct(
7063
Context $context,
7164
StoreManagerInterface $storeManager,
7265
Product $catalogProduct,
7366
Registry $coreRegistry,
7467
LayoutFactory $resultLayoutFactory,
75-
ProductRepositoryInterface $productRepository,
76-
CustomerRepositoryInterface $customerRepository
68+
ProductRepositoryInterface $productRepository
7769
) {
7870
$this->_storeManager = $storeManager;
7971
$this->_coreRegistry = $coreRegistry;
8072
$this->_catalogProduct = $catalogProduct;
8173
$this->resultLayoutFactory = $resultLayoutFactory;
8274
$this->productRepository = $productRepository;
83-
$this->customerRepository = $customerRepository;
8475
parent::__construct($context);
8576
}
8677

@@ -160,11 +151,6 @@ public function renderConfigureResult(\Magento\Framework\Object $configureResult
160151

161152
// Register customer we're working with
162153
$customerId = (int)$configureResult->getCurrentCustomerId();
163-
// TODO: Remove the customer model from the registry once all readers are refactored
164-
if ($customerId) {
165-
$customerData = $this->customerRepository->getById($customerId);
166-
$this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customerData);
167-
}
168154
$this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
169155

170156
// Prepare buy request values

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

+2-23
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
4949
*/
5050
protected $searchCriteriaBuilder;
5151

52-
/**
53-
* @var \Magento\Framework\Api\FilterBuilder
54-
*/
55-
protected $filterBuilder;
56-
5752
/**
5853
* @param \Magento\Catalog\Model\Resource\Attribute $attributeResource
5954
* @param \Magento\Catalog\Helper\Product $productHelper
@@ -62,8 +57,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter
6257
* @param \Magento\Eav\Model\Config $eavConfig
6358
* @param \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory
6459
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
65-
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder
66-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6760
*/
6861
public function __construct(
6962
\Magento\Catalog\Model\Resource\Attribute $attributeResource,
@@ -72,8 +65,7 @@ public function __construct(
7265
\Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository,
7366
\Magento\Eav\Model\Config $eavConfig,
7467
\Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory,
75-
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
76-
\Magento\Framework\Api\FilterBuilder $filterBuilder
68+
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
7769
) {
7870
$this->attributeResource = $attributeResource;
7971
$this->productHelper = $productHelper;
@@ -82,7 +74,6 @@ public function __construct(
8274
$this->eavConfig = $eavConfig;
8375
$this->inputtypeValidatorFactory = $validatorFactory;
8476
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
85-
$this->filterBuilder = $filterBuilder;
8677
}
8778

8879
/**
@@ -209,19 +200,7 @@ public function deleteById($attributeCode)
209200
*/
210201
public function getCustomAttributesMetadata($dataObjectClassName = null)
211202
{
212-
$defaultAttributeSetId = $this->eavConfig
213-
->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
214-
->getDefaultAttributeSetId();
215-
$searchCriteria = $this->searchCriteriaBuilder->addFilters(
216-
[
217-
$this->filterBuilder
218-
->setField('attribute_set_id')
219-
->setValue($defaultAttributeSetId)
220-
->create(),
221-
]
222-
);
223-
224-
return $this->getList($searchCriteria->create())->getItems();
203+
return $this->getList($this->searchCriteriaBuilder->create())->getItems();
225204
}
226205

227206
/**

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

+1-19
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
9595
*/
9696
protected $metadataService;
9797

98-
/**
99-
* @var \Magento\Eav\Model\Config
100-
*/
101-
protected $eavConfig;
102-
10398
/**
10499
* @var \Magento\Framework\Api\ExtensibleDataObjectConverter
105100
*/
@@ -206,7 +201,6 @@ public function __construct(
206201
ImageContentValidatorInterface $contentValidator,
207202
ImageContentInterfaceFactory $contentFactory,
208203
MimeTypeExtensionMap $mimeTypeExtensionMap,
209-
\Magento\Eav\Model\Config $eavConfig,
210204
ImageProcessorInterface $imageProcessor,
211205
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
212206
\Magento\Framework\Search\Request\Builder $requestBuilder,
@@ -232,7 +226,6 @@ public function __construct(
232226
$this->contentValidator = $contentValidator;
233227
$this->contentFactory = $contentFactory;
234228
$this->mimeTypeExtensionMap = $mimeTypeExtensionMap;
235-
$this->eavConfig = $eavConfig;
236229
$this->imageProcessor = $imageProcessor;
237230
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
238231
$this->requestBuilder = $requestBuilder;
@@ -680,19 +673,8 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
680673
/** @var \Magento\Catalog\Model\Resource\Product\Collection $collection */
681674
$collection = $this->collectionFactory->create();
682675
$this->extensionAttributesJoinProcessor->process($collection);
683-
$defaultAttributeSetId = $this->eavConfig
684-
->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
685-
->getDefaultAttributeSetId();
686-
$extendedSearchCriteria = $this->searchCriteriaBuilder->addFilters(
687-
[
688-
$this->filterBuilder
689-
->setField('attribute_set_id')
690-
->setValue($defaultAttributeSetId)
691-
->create(),
692-
]
693-
);
694676

695-
foreach ($this->metadataService->getList($extendedSearchCriteria->create())->getItems() as $metadata) {
677+
foreach ($this->metadataService->getList($this->searchCriteriaBuilder->create())->getItems() as $metadata) {
696678
$collection->addAttributeToSelect($metadata->getAttributeCode());
697679
}
698680
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php

+1-23
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
5858
*/
5959
protected $searchCriteriaBuilderMock;
6060

61-
/**
62-
* @var \PHPUnit_Framework_MockObject_MockObject
63-
*/
64-
protected $filterBuilderMock;
65-
6661
/**
6762
* @var \PHPUnit_Framework_MockObject_MockObject
6863
*/
@@ -89,8 +84,6 @@ protected function setUp()
8984
false);
9085
$this->searchCriteriaBuilderMock =
9186
$this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false);
92-
$this->filterBuilderMock =
93-
$this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false);
9487
$this->searchResultMock =
9588
$this->getMock(
9689
'\Magento\Framework\Api\SearchResultsInterface',
@@ -114,8 +107,7 @@ protected function setUp()
114107
$this->eavAttributeRepositoryMock,
115108
$this->eavConfigMock,
116109
$this->validatorFactoryMock,
117-
$this->searchCriteriaBuilderMock,
118-
$this->filterBuilderMock
110+
$this->searchCriteriaBuilderMock
119111
);
120112
}
121113

@@ -169,20 +161,6 @@ public function testDeleteById()
169161

170162
public function testGetCustomAttributesMetadata()
171163
{
172-
$filterMock = $this->getMock('Magento\Framework\Service\V1\Data\Filter', [], [], '', false);
173-
$this->filterBuilderMock->expects($this->once())
174-
->method('setField')
175-
->with('attribute_set_id')
176-
->willReturnSelf();
177-
$this->filterBuilderMock->expects($this->once())
178-
->method('setValue')
179-
->with(4)
180-
->willReturnSelf();
181-
$this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock);
182-
$this->searchCriteriaBuilderMock->expects($this->once())
183-
->method('addFilters')
184-
->with([$filterMock])
185-
->willReturnSelf();
186164
$searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false);
187165
$this->searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock);
188166
$itemMock = $this->getMock('Magento\Catalog\Api\Data\ProductInterface');

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

+9-16
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ protected function setUp()
216216
false
217217
);
218218
$this->resourceModelMock = $this->getMock('\Magento\Catalog\Model\Resource\Product', [], [], '', false);
219-
$this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false);
220-
$this->eavConfigMock->expects($this->any())->method('getEntityType')
221-
->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4]));
222219
$this->objectManager = new ObjectManager($this);
223220
$this->extensibleDataObjectConverterMock = $this
224221
->getMockBuilder('\Magento\Framework\Api\ExtensibleDataObjectConverter')
@@ -229,7 +226,13 @@ protected function setUp()
229226
->disableOriginalConstructor()->getMock();
230227
$this->mimeTypeExtensionMapMock =
231228
$this->getMockBuilder('Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap')->getMock();
232-
$this->contentFactoryMock = $this->getMock('Magento\Framework\Api\Data\ImageContentInterfaceFactory', ['create'], [], '', false);
229+
$this->contentFactoryMock = $this->getMock(
230+
'Magento\Framework\Api\Data\ImageContentInterfaceFactory',
231+
['create'],
232+
[],
233+
'',
234+
false
235+
);
233236
$this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface')
234237
->disableOriginalConstructor()
235238
->getMock();
@@ -271,7 +274,6 @@ protected function setUp()
271274
'searchResultsFactory' => $this->searchResultsFactoryMock,
272275
'extensibleDataObjectConverter' => $this->extensibleDataObjectConverterMock,
273276
'optionConverter' => $optionConverter,
274-
'eavConfig' => $this->eavConfigMock,
275277
'contentValidator' => $this->contentValidatorMock,
276278
'fileSystem' => $this->fileSystemMock,
277279
'contentFactory' => $this->contentFactoryMock,
@@ -595,8 +597,6 @@ public function testGetList()
595597
$searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface', [], [], '', false);
596598
$attributeCode = 'attribute_code';
597599
$collectionMock = $this->getMock('\Magento\Catalog\Model\Resource\Product\Collection', [], [], '', false);
598-
$filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false);
599-
$searchCriteriaBuilderMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false);
600600
$extendedSearchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false);
601601
$productAttributeSearchResultsMock = $this->getMockForAbstractClass(
602602
'\Magento\Catalog\Api\Data\ProductAttributeInterface',
@@ -620,15 +620,8 @@ public function testGetList()
620620
$itemsMock = $this->getMock('\Magento\Framework\Object', [], [], '', false);
621621

622622
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock);
623-
$this->filterBuilderMock->expects($this->any())->method('setField')->with('attribute_set_id')
624-
->will($this->returnSelf());
625-
$this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock);
626-
$this->filterBuilderMock->expects($this->once())->method('setValue')
627-
->with(4)
628-
->willReturn($this->filterBuilderMock);
629-
$this->searchCriteriaBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock])
630-
->willReturn($searchCriteriaBuilderMock);
631-
$searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($extendedSearchCriteriaMock);
623+
$this->searchCriteriaBuilderMock->expects($this->once())->method('create')
624+
->willReturn($extendedSearchCriteriaMock);
632625
$this->metadataServiceMock->expects($this->once())->method('getList')->with($extendedSearchCriteriaMock)
633626
->willReturn($productAttributeSearchResultsMock);
634627
$productAttributeSearchResultsMock->expects($this->once())->method('getItems')

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ define([
7474
$('body').trigger(self.options.processStop);
7575
}
7676

77-
if (res.backUrl) {
78-
window.location = res.backUrl;
77+
if (res.redirect) {
78+
window.location = res.redirect;
7979
return;
8080
}
8181
if (res.messages) {

app/code/Magento/Checkout/Block/Registration.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,31 @@ class Registration extends \Magento\Framework\View\Element\Template
2424
*/
2525
protected $registration;
2626

27+
/**
28+
* @var \Magento\Customer\Api\AccountManagementInterface
29+
*/
30+
protected $accountManagement;
31+
2732
/**
2833
* @param Template\Context $context
2934
* @param \Magento\Checkout\Model\Session $checkoutSession
3035
* @param \Magento\Customer\Model\Session $customerSession
3136
* @param \Magento\Customer\Model\Registration $registration
37+
* @param \Magento\Customer\Api\AccountManagementInterface $accountManagement
3238
* @param array $data
3339
*/
3440
public function __construct(
3541
Template\Context $context,
3642
\Magento\Checkout\Model\Session $checkoutSession,
3743
\Magento\Customer\Model\Session $customerSession,
3844
\Magento\Customer\Model\Registration $registration,
45+
\Magento\Customer\Api\AccountManagementInterface $accountManagement,
3946
array $data = []
4047
) {
4148
$this->checkoutSession = $checkoutSession;
4249
$this->customerSession = $customerSession;
4350
$this->registration = $registration;
51+
$this->accountManagement = $accountManagement;
4452
parent::__construct($context, $data);
4553
}
4654

@@ -69,7 +77,11 @@ public function getCreateAccountUrl()
6977
*/
7078
public function toHtml()
7179
{
72-
if ($this->customerSession->isLoggedIn() || !$this->registration->isAllowed()) {
80+
if (
81+
$this->customerSession->isLoggedIn()
82+
|| !$this->registration->isAllowed()
83+
|| !$this->accountManagement->isEmailAvailable($this->getEmailAddress())
84+
) {
7385
return '';
7486
}
7587
return parent::toHtml();

app/code/Magento/Checkout/Controller/Cart/Add.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function goBack($backUrl = null, $product = null)
169169
$result = [];
170170

171171
if ($backUrl || $backUrl = $this->getBackUrl()) {
172-
$result['backUrl'] = $backUrl;
172+
$result['redirect'] = $backUrl;
173173
} else {
174174
if ($product && !$product->getIsSalable()) {
175175
$result['product'] = [

0 commit comments

Comments
 (0)