Skip to content

Commit 79b4b2a

Browse files
author
Magento CICD
authored
merge magento/2.1-develop into magento-mpi/MPI-PR-2.1-develop
2 parents 05baf1a + 0f56de1 commit 79b4b2a

File tree

19 files changed

+374
-77
lines changed

19 files changed

+374
-77
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,25 +369,55 @@ protected function getAttributeValues($entityIds, $storeId)
369369
}
370370
$values = [];
371371

372-
foreach ($entityIds as $entityId) {
373-
$values[$entityId] = [];
372+
$linkIds = $this->getLinkIds($entityIds);
373+
foreach ($linkIds as $linkId) {
374+
$values[$linkId] = [];
374375
}
376+
375377
$attributes = $this->getAttributes();
376378
$attributesType = ['varchar', 'int', 'decimal', 'text', 'datetime'];
379+
$linkField = $this->getCategoryMetadata()->getLinkField();
377380
foreach ($attributesType as $type) {
378381
foreach ($this->getAttributeTypeValues($type, $entityIds, $storeId) as $row) {
379-
if (isset($row[$this->getCategoryMetadata()->getLinkField()]) && isset($row['attribute_id'])) {
382+
if (isset($row[$linkField]) && isset($row['attribute_id'])) {
380383
$attributeId = $row['attribute_id'];
381384
if (isset($attributes[$attributeId])) {
382385
$attributeCode = $attributes[$attributeId]['attribute_code'];
383-
$values[$row[$this->getCategoryMetadata()->getLinkField()]][$attributeCode] = $row['value'];
386+
$values[$row[$linkField]][$attributeCode] = $row['value'];
384387
}
385388
}
386389
}
387390
}
391+
388392
return $values;
389393
}
390394

395+
/**
396+
* Translate entity ids into link ids
397+
*
398+
* Used for rows with no EAV attributes set.
399+
*
400+
* @param array $entityIds
401+
* @return array
402+
*/
403+
private function getLinkIds(array $entityIds)
404+
{
405+
$linkField = $this->getCategoryMetadata()->getLinkField();
406+
if ($linkField === 'entity_id') {
407+
return $entityIds;
408+
}
409+
410+
$select = $this->connection->select()->from(
411+
['e' => $this->connection->getTableName($this->getTableName('catalog_category_entity'))],
412+
[$linkField]
413+
)->where(
414+
'e.entity_id IN (?)',
415+
$entityIds
416+
);
417+
418+
return $this->connection->fetchCol($select);
419+
}
420+
391421
/**
392422
* Return attribute values for given entities and store of specific attribute type
393423
*

app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Full.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,22 @@ protected function populateFlatTables(array $stores)
6464
}
6565
/** @TODO Do something with chunks */
6666
$categoriesIdsChunks = array_chunk($categoriesIds[$store->getRootCategoryId()], 500);
67+
6768
foreach ($categoriesIdsChunks as $categoriesIdsChunk) {
6869
$attributesData = $this->getAttributeValues($categoriesIdsChunk, $store->getId());
70+
$linkField = $this->categoryMetadata->getLinkField();
71+
6972
$data = [];
7073
foreach ($categories[$store->getRootCategoryId()] as $category) {
71-
if (!isset($attributesData[$category[$this->categoryMetadata->getLinkField()]])) {
74+
if (!isset($attributesData[$category[$linkField]])) {
7275
continue;
7376
}
7477
$category['store_id'] = $store->getId();
7578
$data[] = $this->prepareValuesToInsert(
76-
array_merge($category, $attributesData[$category[$this->categoryMetadata->getLinkField()]])
79+
array_merge($category, $attributesData[$category[$linkField]])
7780
);
7881
}
82+
7983
$this->connection->insertMultiple(
8084
$this->addTemporaryTableSuffix($this->getMainStoreTable($store->getId())),
8185
$data

app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,24 @@ public function reindex(array $entityIds = [], $useTempTable = false)
6969
$categoriesIdsChunk = $this->filterIdsByStore($categoriesIdsChunk, $store);
7070

7171
$attributesData = $this->getAttributeValues($categoriesIdsChunk, $store->getId());
72+
$linkField = $this->categoryMetadata->getLinkField();
7273
$data = [];
7374
foreach ($categoriesIdsChunk as $categoryId) {
74-
if (!isset($attributesData[$categoryId])) {
75-
continue;
76-
}
77-
7875
try {
7976
$category = $this->categoryRepository->get($categoryId);
8077
} catch (NoSuchEntityException $e) {
8178
continue;
8279
}
8380

81+
$categoryData = $category->getData();
82+
if (!isset($attributesData[$categoryData[$linkField]])) {
83+
continue;
84+
}
85+
8486
$data[] = $this->prepareValuesToInsert(
8587
array_merge(
86-
$category->getData(),
87-
$attributesData[$categoryId],
88+
$categoryData,
89+
$attributesData[$categoryData[$linkField]],
8890
['store_id' => $store->getId()]
8991
)
9092
);

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ protected function _createTemporaryFlatTable($storeId)
179179

180180
$columnComment = isset($fieldProp['comment']) ? $fieldProp['comment'] : $fieldName;
181181

182+
if ($fieldName == 'created_at') {
183+
$columnDefinition['nullable'] = true;
184+
$columnDefinition['default'] = null;
185+
}
186+
182187
$table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);
183188
}
184189

app/code/Magento/Catalog/Model/Product/Option/Value.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public function getProduct()
191191
public function saveValues()
192192
{
193193
foreach ($this->getValues() as $value) {
194+
$this->isDeleted(false);
194195
$this->setData(
195196
$value
196197
)->setData(

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ define(
261261
emailValidationResult = customer.isLoggedIn();
262262

263263
if (!quote.shippingMethod()) {
264-
this.errorValidationMessage('Please specify a shipping method.');
264+
this.errorValidationMessage($t('Please specify a shipping method.'));
265265

266266
return false;
267267
}

app/code/Magento/Customer/Api/CustomerRepositoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
3737
public function get($email, $websiteId = null);
3838

3939
/**
40-
* Get customer by customer ID.
40+
* Get customer by Customer ID.
4141
*
4242
* @param int $customerId
4343
* @return \Magento\Customer\Api\Data\CustomerInterface
@@ -69,7 +69,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
6969
public function delete(\Magento\Customer\Api\Data\CustomerInterface $customer);
7070

7171
/**
72-
* Delete customer by ID.
72+
* Delete customer by Customer ID.
7373
*
7474
* @param int $customerId
7575
* @return bool true on success

app/code/Magento/Customer/Controller/Account/Confirm.php

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
78
namespace Magento\Customer\Controller\Account;
89

10+
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
11+
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
912
use Magento\Customer\Model\Url;
1013
use Magento\Framework\App\Action\Context;
1114
use Magento\Customer\Model\Session;
1215
use Magento\Framework\App\Config\ScopeConfigInterface;
16+
use Magento\Framework\App\ObjectManager;
1317
use Magento\Store\Model\StoreManagerInterface;
1418
use Magento\Customer\Api\AccountManagementInterface;
1519
use Magento\Customer\Api\CustomerRepositoryInterface;
@@ -32,10 +36,10 @@ class Confirm extends \Magento\Customer\Controller\AbstractAccount
3236
/** @var StoreManagerInterface */
3337
protected $storeManager;
3438

35-
/** @var AccountManagementInterface */
39+
/** @var AccountManagementInterface */
3640
protected $customerAccountManagement;
3741

38-
/** @var CustomerRepositoryInterface */
42+
/** @var CustomerRepositoryInterface */
3943
protected $customerRepository;
4044

4145
/** @var Address */
@@ -49,6 +53,16 @@ class Confirm extends \Magento\Customer\Controller\AbstractAccount
4953
*/
5054
protected $session;
5155

56+
/**
57+
* @var CookieMetadataFactory
58+
*/
59+
private $cookieMetadataFactory;
60+
61+
/**
62+
* @var PhpCookieManager
63+
*/
64+
private $cookieMetadataManager;
65+
5266
/**
5367
* @param Context $context
5468
* @param Session $customerSession
@@ -58,6 +72,9 @@ class Confirm extends \Magento\Customer\Controller\AbstractAccount
5872
* @param CustomerRepositoryInterface $customerRepository
5973
* @param Address $addressHelper
6074
* @param UrlFactory $urlFactory
75+
* @param CookieMetadataFactory $cookieMetadataFactory
76+
* @param PhpCookieManager $cookieMetadataManager
77+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6178
*/
6279
public function __construct(
6380
Context $context,
@@ -67,7 +84,9 @@ public function __construct(
6784
AccountManagementInterface $customerAccountManagement,
6885
CustomerRepositoryInterface $customerRepository,
6986
Address $addressHelper,
70-
UrlFactory $urlFactory
87+
UrlFactory $urlFactory,
88+
CookieMetadataFactory $cookieMetadataFactory = null,
89+
PhpCookieManager $cookieMetadataManager = null
7190
) {
7291
$this->session = $customerSession;
7392
$this->scopeConfig = $scopeConfig;
@@ -76,6 +95,11 @@ public function __construct(
7695
$this->customerRepository = $customerRepository;
7796
$this->addressHelper = $addressHelper;
7897
$this->urlModel = $urlFactory->create();
98+
$this->cookieMetadataFactory = $cookieMetadataFactory ?: ObjectManager::getInstance()
99+
->get(CookieMetadataFactory::class);
100+
$this->cookieMetadataManager = $cookieMetadataManager ?: ObjectManager::getInstance()
101+
->get(PhpCookieManager::class);
102+
79103
parent::__construct($context);
80104
}
81105

@@ -100,6 +124,8 @@ public function execute()
100124
throw new \Exception(__('Bad request.'));
101125
}
102126

127+
//clean customer cookies
128+
$this->cleanCookie('mage-cache-sessid');
103129
// log in and send greeting email
104130
$customerEmail = $this->customerRepository->getById($customerId)->getEmail();
105131
$customer = $this->customerAccountManagement->activate($customerEmail, $key);
@@ -121,7 +147,7 @@ public function execute()
121147
/**
122148
* Retrieve success message
123149
*
124-
* @return string
150+
* @return \Magento\Framework\Phrase
125151
*/
126152
protected function getSuccessMessage()
127153
{
@@ -166,4 +192,21 @@ protected function getSuccessRedirect()
166192
}
167193
return $this->_redirect->success($backUrl ? $backUrl : $successUrl);
168194
}
195+
196+
/**
197+
* Clean cookie by name.
198+
*
199+
* @param String $cookieName
200+
* @return void
201+
*/
202+
private function cleanCookie($cookieName)
203+
{
204+
if ($this->cookieMetadataManager->getCookie($cookieName)) {
205+
$this->cookieMetadataManager->deleteCookie(
206+
$cookieName,
207+
$this->cookieMetadataFactory->createCookieMetadata()
208+
->setPath('/')
209+
);
210+
}
211+
}
169212
}

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,13 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
523523
default:
524524
throw new InputException(
525525
__(
526-
'Invalid value of "%value" provided for the %fieldName field.',
527-
['value' => $template, 'fieldName' => 'email type']
526+
'Invalid value of "%value" provided for the %fieldName field. Possible values are %template1 or %template2.',
527+
[
528+
'value' => $template,
529+
'fieldName' => 'template',
530+
'template1' => AccountManagement::EMAIL_REMINDER,
531+
'template2' => AccountManagement::EMAIL_RESET
532+
]
528533
)
529534
);
530535
}

0 commit comments

Comments
 (0)