Skip to content

Commit 076dc1e

Browse files
committed
Merge branch 'develop' of https://github.com/magento-qmt/magento2ce into MTA-3333
2 parents 07106af + f06e0d9 commit 076dc1e

File tree

176 files changed

+2423
-892
lines changed

Some content is hidden

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

176 files changed

+2423
-892
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/CatalogImportExport/Model/Import/Product.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
use Magento\ImportExport\Model\Import;
1717
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError;
1818
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
19-
use Magento\Catalog\Api\Data\ProductInterface;
2019
use Magento\ImportExport\Model\Import\Entity\AbstractEntity;
21-
20+
use Magento\Catalog\Model\Product\Visibility;
2221
/**
2322
* Import entity product model
2423
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -104,6 +103,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
104103
*/
105104
const COL_CATEGORY = 'categories';
106105

106+
/**
107+
* Column product visibility.
108+
*/
109+
const COL_VISIBILITY = 'visibility';
110+
107111
/**
108112
* Column product sku.
109113
*/
@@ -2286,7 +2290,8 @@ public function validateRow(array $rowData, $rowNum)
22862290
}
22872291
// validate custom options
22882292
$this->getOptionEntity()->validateRow($rowData, $rowNum);
2289-
if (!empty($rowData[self::URL_KEY]) || !empty($rowData[self::COL_NAME])) {
2293+
2294+
if ($this->isNeedToValidateUrlKey($rowData)) {
22902295
$urlKey = $this->getUrlKey($rowData);
22912296
$storeCodes = empty($rowData[self::COL_STORE_VIEW_CODE])
22922297
? array_flip($this->storeResolver->getStoreCodeToId())
@@ -2308,6 +2313,18 @@ public function validateRow(array $rowData, $rowNum)
23082313
return !$this->getErrorAggregator()->isRowInvalid($rowNum);
23092314
}
23102315

2316+
/**
2317+
* @param array $rowData
2318+
* @return bool
2319+
*/
2320+
private function isNeedToValidateUrlKey($rowData)
2321+
{
2322+
return (!empty($rowData[self::URL_KEY]) || !empty($rowData[self::COL_NAME]))
2323+
&& (empty($rowData[self::COL_VISIBILITY])
2324+
|| $rowData[self::COL_VISIBILITY]
2325+
!== (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]);
2326+
}
2327+
23112328
/**
23122329
* Prepare new SKU data
23132330
*

app/code/Magento/CatalogRule/Api/CatalogRuleRepositoryInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@
55
*/
66
namespace Magento\CatalogRule\Api;
77

8+
/**
9+
* Interface CatalogRuleRepositoryInterface
10+
* @api
11+
*/
812
interface CatalogRuleRepositoryInterface
913
{
1014
/**
11-
* @api
1215
* @param \Magento\CatalogRule\Api\Data\RuleInterface $rule
1316
* @return \Magento\CatalogRule\Api\Data\RuleInterface
1417
* @throws \Magento\Framework\Exception\CouldNotSaveException
1518
*/
1619
public function save(\Magento\CatalogRule\Api\Data\RuleInterface $rule);
1720

1821
/**
19-
* @api
2022
* @param int $ruleId
2123
* @return \Magento\CatalogRule\Api\Data\RuleInterface
2224
* @throws \Magento\Framework\Exception\NoSuchEntityException
2325
*/
2426
public function get($ruleId);
2527

2628
/**
27-
* @api
2829
* @param \Magento\CatalogRule\Api\Data\RuleInterface $rule
2930
* @return bool
3031
* @throws \Magento\Framework\Exception\CouldNotDeleteException
3132
*/
3233
public function delete(\Magento\CatalogRule\Api\Data\RuleInterface $rule);
3334

3435
/**
35-
* @api
3636
* @param int $ruleId
3737
* @return bool
3838
* @throws \Magento\Framework\Exception\CouldNotDeleteException

app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function generateProductUrls($websiteId, $originWebsiteId)
113113
$collection = $this->productFactory->create()
114114
->getCollection()
115115
->addCategoryIds()
116-
->addAttributeToSelect(['name', 'url_path', 'url_key'])
116+
->addAttributeToSelect(['name', 'url_path', 'url_key', 'visibility'])
117117
->addWebsiteFilter($websiteIds);
118118
foreach ($collection as $product) {
119119
/** @var \Magento\Catalog\Model\Product $product */

0 commit comments

Comments
 (0)