Skip to content

Commit 415a4b7

Browse files
author
Cari Spruiell
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-52993-Github#2958-Image-Media-Uploader
2 parents fff497f + 3fbefa4 commit 415a4b7

File tree

247 files changed

+4032
-1242
lines changed

Some content is hidden

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

247 files changed

+4032
-1242
lines changed

app/code/Magento/Backend/Model/Session/Quote.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,16 @@ public function __construct(
150150
*/
151151
public function getQuote()
152152
{
153-
$cartManagement = $this->getCartManagement();
154-
155153
if ($this->_quote === null) {
154+
$this->_quote = $this->quoteFactory->create();
156155
if ($this->getStoreId()) {
157156
if (!$this->getQuoteId()) {
158-
$this->setQuoteId($cartManagement->createEmptyCart());
159-
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
160157
$this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId());
161-
$this->_quote->setIsActive(false);
158+
$this->_quote->setStoreId($this->getStoreId());
159+
160+
$this->quoteRepository->save($this->_quote);
161+
$this->setQuoteId($this->_quote->getId());
162+
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
162163
} else {
163164
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
164165
$this->_quote->setStoreId($this->getStoreId());
@@ -167,6 +168,7 @@ public function getQuote()
167168
if ($this->getCustomerId() && $this->getCustomerId() != $this->_quote->getCustomerId()) {
168169
$customer = $this->customerRepository->getById($this->getCustomerId());
169170
$this->_quote->assignCustomer($customer);
171+
$this->quoteRepository->save($this->_quote);
170172
}
171173
}
172174
$this->_quote->setIgnoreOldQty(true);
@@ -176,18 +178,6 @@ public function getQuote()
176178
return $this->_quote;
177179
}
178180

179-
/**
180-
* @return CartManagementInterface
181-
* @deprecated
182-
*/
183-
private function getCartManagement()
184-
{
185-
if ($this->cartManagement === null) {
186-
$this->cartManagement = ObjectManager::getInstance()->get(CartManagementInterface::class);
187-
}
188-
return $this->cartManagement;
189-
}
190-
191181
/**
192182
* Retrieve store model object
193183
*

app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
3333
protected $cookieManagerMock;
3434

3535
/**
36-
* @var \Magento\Framework\Session\StorageInterface|\PHPUnit_Framework_MockObject_MockObject
36+
* @var \Magento\Framework\Session\StorageInterface
3737
*/
38-
protected $storageMock;
38+
protected $storage;
3939

4040
/**
4141
* @var \Magento\Framework\Session\ValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -166,12 +166,7 @@ protected function setUp()
166166
'',
167167
false
168168
);
169-
$this->storageMock = $this->getMockForAbstractClass(
170-
'Magento\Framework\Session\StorageInterface',
171-
[],
172-
'',
173-
false
174-
);
169+
$this->storage = new \Magento\Framework\Session\Storage();
175170
$this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface');
176171
$this->cookieMetadataFactoryMock = $this->getMock(
177172
'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory',
@@ -219,7 +214,7 @@ protected function setUp()
219214
'sessionConfig' => $this->sessionConfigMock,
220215
'saveHandler' => $this->saveHandlerMock,
221216
'validator' => $this->validatorMock,
222-
'storage' => $this->storageMock,
217+
'storage' => $this->storage,
223218
'cookieManager' => $this->cookieManagerMock,
224219
'cookieMetadataFactory' => $this->cookieMetadataFactoryMock,
225220
'appState' => $appStateMock,
@@ -249,20 +244,72 @@ public function testGetQuoteWithoutQuoteId()
249244
$customerId = 66;
250245
$customerGroupId = 77;
251246

252-
$this->cartManagementMock->expects($this->once())->method('createEmptyCart')->willReturn($quoteId);
253-
254247
$this->quote->expects($this->any())
255248
->method('getQuoteId')
256249
->will($this->returnValue(null));
257250
$this->quote->expects($this->any())
258251
->method('setQuoteId')
259252
->with($quoteId);
253+
$cartInterfaceMock = $this->getMock(
254+
'\Magento\Quote\Api\Data\CartInterface',
255+
[
256+
'getId',
257+
'setId',
258+
'getCreatedAt',
259+
'setCreatedAt',
260+
'getUpdatedAt',
261+
'setUpdatedAt',
262+
'getConvertedAt',
263+
'setConvertedAt',
264+
'getIsActive',
265+
'setIsActive',
266+
'getIsVirtual',
267+
'getItems',
268+
'setItems',
269+
'getItemsCount',
270+
'setItemsCount',
271+
'getItemsQty',
272+
'setItemsQty',
273+
'getCustomer',
274+
'setCustomer',
275+
'getBillingAddress',
276+
'setBillingAddress',
277+
'getReservedOrderId',
278+
'setReservedOrderId',
279+
'getOrigOrderId',
280+
'setOrigOrderId',
281+
'getCurrency',
282+
'setCurrency',
283+
'getCustomerIsGuest',
284+
'setCustomerIsGuest',
285+
'getCustomerNote',
286+
'setCustomerNote',
287+
'getCustomerNoteNotify',
288+
'setCustomerNoteNotify',
289+
'getCustomerTaxClassId',
290+
'setCustomerTaxClassId',
291+
'getStoreId',
292+
'setStoreId',
293+
'getExtensionAttributes',
294+
'setExtensionAttributes',
295+
'setIgnoreOldQty',
296+
'setIsSuperMode',
297+
'setCustomerGroupId'
298+
]
299+
);
300+
$this->quoteFactoryMock->expects($this->once())
301+
->method('create')
302+
->willReturn($cartInterfaceMock);
260303
$this->quote->expects($this->any())
261304
->method('getStoreId')
262305
->will($this->returnValue($storeId));
263306
$this->quote->expects($this->any())
264307
->method('getCustomerId')
265308
->will($this->returnValue($customerId));
309+
$cartInterfaceMock->expects($this->atLeastOnce())
310+
->method('getId')
311+
->willReturn($quoteId);
312+
266313

267314
$defaultGroup = $this->getMockBuilder('Magento\Customer\Api\Data\GroupInterface')
268315
->getMock();
@@ -297,14 +344,10 @@ public function testGetQuoteWithoutQuoteId()
297344
false
298345
);
299346
$this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock);
300-
$quoteMock->expects($this->once())
347+
$cartInterfaceMock->expects($this->once())
301348
->method('setCustomerGroupId')
302349
->with($customerGroupId)
303350
->will($this->returnSelf());
304-
$quoteMock->expects($this->once())
305-
->method('setIsActive')
306-
->with(false)
307-
->will($this->returnSelf());
308351
$quoteMock->expects($this->once())
309352
->method('assignCustomer')
310353
->with($dataCustomerMock);

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,9 @@
133133
</arguments>
134134
</type>
135135
<preference for="Magento\Framework\App\Router\PathConfigInterface" type="Magento\Backend\Model\AdminPathConfig" />
136+
<type name="Magento\Framework\View\Page\Config">
137+
<arguments>
138+
<argument name="isIncludesAvailable" xsi:type="boolean">false</argument>
139+
</arguments>
140+
</type>
136141
</config>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
*/
77
namespace Magento\Catalog\Api;
88

9+
/**
10+
* Interface AttributeSetFinderInterface
11+
* @api
12+
*/
913
interface AttributeSetFinderInterface
1014
{
1115
/**

app/code/Magento/Catalog/Api/Data/CategoryProductSearchResultInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
*/
77
namespace Magento\Catalog\Api\Data;
88

9+
/**
10+
* Interface CategoryProductSearchResultInterface
11+
* @api
12+
*/
913
interface CategoryProductSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface
1014
{
1115
/**

app/code/Magento/Catalog/Api/Data/ProductOptionInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* Product option interface
12+
* @api
1213
*/
1314
interface ProductOptionInterface extends ExtensibleDataInterface
1415
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace Magento\Catalog\Api;
88

9+
/**
10+
* Interface ProductWebsiteLinkRepositoryInterface
11+
* @api
12+
*/
913
interface ProductWebsiteLinkRepositoryInterface
1014
{
1115
/**

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
170170
$product->lockAttribute('media');
171171
}
172172

173-
if ($this->storeManager->hasSingleStore() && empty($product->getWebsiteIds())) {
174-
$product->setWebsiteIds([$this->storeManager->getStore(true)->getWebsite()->getId()]);
175-
}
176-
177173
/**
178174
* Check "Use Default Value" checkboxes values
179175
*/

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ public function delete($object)
315315
*/
316316
protected function _saveWebsiteIds($product)
317317
{
318-
if (empty(array_diff($product->getWebsiteIds(), [0]))) {
319-
$product->setWebsiteIds([1]);
318+
if ($this->_storeManager->isSingleStoreMode()) {
319+
$id = $this->_storeManager->getDefaultStoreView()->getWebsiteId();
320+
$product->setWebsiteIds([$id]);
320321
}
321322
$websiteIds = $product->getWebsiteIds();
322323

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
5656
/**
5757
* @var MetadataPool
5858
*/
59-
protected $metadataPool;
59+
private $metadataPool;
6060

6161
/**
6262
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
@@ -219,7 +219,8 @@ public function addProductFilter($products)
219219
if (!is_array($products)) {
220220
$products = [$products];
221221
}
222-
$this->getSelect()->where('links.product_id IN (?)', $products);
222+
$identifierField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getIdentifierField();
223+
$this->getSelect()->where("product_entity_table.$identifierField IN (?)", $products);
223224
$this->_hasLinkFilter = true;
224225
}
225226

@@ -258,6 +259,7 @@ protected function _beforeLoad()
258259
{
259260
if ($this->getLinkModel()) {
260261
$this->_joinLinks();
262+
$this->joinProductsToLinks();
261263
}
262264
return parent::_beforeLoad();
263265
}
@@ -423,12 +425,28 @@ public function addLinkAttributeToFilter($code, $condition)
423425
/**
424426
* Get MetadataPool instance
425427
* @return MetadataPool
428+
* @deprecated
426429
*/
427-
protected function getMetadataPool()
430+
private function getMetadataPool()
428431
{
429432
if (!$this->metadataPool) {
430433
$this->metadataPool = ObjectManager::getInstance()->get(MetadataPool::class);
431434
}
432435
return $this->metadataPool;
433436
}
437+
438+
/**
439+
* Join Product To Links
440+
* @return void
441+
*/
442+
private function joinProductsToLinks()
443+
{
444+
if ($this->_hasLinkFilter) {
445+
$metaDataPool = $this->getMetadataPool()->getMetadata(ProductInterface::class);
446+
$linkField = $metaDataPool->getLinkField();
447+
$entityTable = $metaDataPool->getEntityTable();
448+
$this->getSelect()
449+
->join(['product_entity_table' => $entityTable], "links.product_id = product_entity_table.$linkField", []);
450+
}
451+
}
434452
}

0 commit comments

Comments
 (0)