Skip to content

Commit f8474ca

Browse files
authored
Merge pull request #8640 from magento-l3/Tier4-PR-Delivery-11-18-23
Tier4 PR Delivery 11.18.23
2 parents 601dec4 + c922e63 commit f8474ca

File tree

33 files changed

+2127
-295
lines changed

33 files changed

+2127
-295
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,7 @@ private function preparePageMetadata(ResultPage $resultPage, $product)
130130
$pageConfig->setKeywords($product->getName());
131131
}
132132

133-
$description = $product->getMetaDescription();
134-
if ($description) {
135-
$pageConfig->setDescription($description);
136-
} else {
137-
$productDescription = is_string($product->getDescription()) ?
138-
$this->string->substr(strip_tags($product->getDescription()), 0, 255) : '';
139-
$pageConfig->setDescription($productDescription);
140-
}
133+
$pageConfig->setDescription($product->getMetaDescription());
141134

142135
if ($this->_catalogProduct->canUseCanonicalTag()) {
143136
$pageConfig->addRemotePageAsset(

app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/Validation.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,19 @@ public function afterValidate(Rule $rule, $validateResult, DataObject $product)
4949
{
5050
if (!$validateResult && ($configurableProducts = $this->configurable->getParentIdsByChild($product->getId()))) {
5151
foreach ($configurableProducts as $configurableProductId) {
52-
$configurableProduct = $this->productRepository->getById(
53-
$configurableProductId,
54-
false,
55-
$product->getStoreId()
56-
);
57-
$validateResult = $rule->getConditions()->validate($configurableProduct);
58-
// If any of configurable product is valid for current rule, then their sub-product must be valid too
59-
if ($validateResult) {
60-
break;
52+
try {
53+
$configurableProduct = $this->productRepository->getById(
54+
$configurableProductId,
55+
false,
56+
$product->getStoreId()
57+
);
58+
$validateResult = $rule->getConditions()->validate($configurableProduct);
59+
//If any of configurable product is valid for current rule, then their sub-product must be valid too
60+
if ($validateResult) {
61+
break;
62+
}
63+
} catch (\Exception $e) {
64+
continue;
6165
}
6266
}
6367
}

app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ValidationTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,32 @@ protected function setUp(): void
6666
);
6767
}
6868

69+
/**
70+
* @return void
71+
*/
72+
public function testAfterValidateConfigurableProductException(): void
73+
{
74+
$validationResult = false;
75+
$parentsIds = [2];
76+
$productId = 1;
77+
78+
$this->productMock->expects($this->once())
79+
->method('getId')
80+
->willReturn($productId);
81+
$this->configurableMock->expects($this->once())
82+
->method('getParentIdsByChild')
83+
->with($productId)
84+
->willReturn($parentsIds);
85+
$this->productRepositoryMock->expects($this->once())
86+
->method('getById')
87+
->willThrowException(new \Exception('Faulty configurable product'));
88+
89+
$this->assertSame(
90+
$validationResult,
91+
$this->validation->afterValidate($this->ruleMock, $validationResult, $this->productMock)
92+
);
93+
}
94+
6995
/**
7096
* @param $parentsIds
7197
* @param $validationResult

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Customer\Model\AuthenticationInterface;
1717
use Magento\Customer\Model\Customer\Mapper;
1818
use Magento\Customer\Model\EmailNotificationInterface;
19+
use Magento\Customer\Model\Metadata\Form\File;
1920
use Magento\Framework\App\CsrfAwareActionInterface;
2021
use Magento\Framework\App\ObjectManager;
2122
use Magento\Framework\App\Request\InvalidRequestException;
@@ -136,6 +137,7 @@ class EditPost extends AbstractAccount implements CsrfAwareActionInterface, Http
136137
* @param SessionCleanerInterface|null $sessionCleaner
137138
* @param AccountConfirmation|null $accountConfirmation
138139
* @param Url|null $customerUrl
140+
* @param Mapper|null $customerMapper
139141
*/
140142
public function __construct(
141143
Context $context,
@@ -149,7 +151,8 @@ public function __construct(
149151
?Filesystem $filesystem = null,
150152
?SessionCleanerInterface $sessionCleaner = null,
151153
?AccountConfirmation $accountConfirmation = null,
152-
?Url $customerUrl = null
154+
?Url $customerUrl = null,
155+
?Mapper $customerMapper = null
153156
) {
154157
parent::__construct($context);
155158
$this->session = $customerSession;
@@ -164,6 +167,7 @@ public function __construct(
164167
$this->accountConfirmation = $accountConfirmation ?: ObjectManager::getInstance()
165168
->get(AccountConfirmation::class);
166169
$this->customerUrl = $customerUrl ?: ObjectManager::getInstance()->get(Url::class);
170+
$this->customerMapper = $customerMapper ?: ObjectManager::getInstance()->get(Mapper::class);
167171
}
168172

169173
/**
@@ -233,9 +237,15 @@ public function execute()
233237
$customer = $this->getCustomerDataObject($this->session->getCustomerId());
234238
$customerCandidate = $this->populateNewCustomerDataObject($this->_request, $customer);
235239

236-
$attributeToDelete = $this->_request->getParam('delete_attribute_value');
237-
if ($attributeToDelete !== null) {
238-
$this->deleteCustomerFileAttribute($customerCandidate, $attributeToDelete);
240+
$attributeToDelete = (string)$this->_request->getParam('delete_attribute_value');
241+
if ($attributeToDelete !== "") {
242+
$attributesToDelete = $this->prepareAttributesToDelete($attributeToDelete);
243+
foreach ($attributesToDelete as $attribute) {
244+
$uploadedValue = $this->_request->getParam($attribute . File::UPLOADED_FILE_SUFFIX);
245+
if ((string)$uploadedValue === "") {
246+
$this->deleteCustomerFileAttribute($customerCandidate, $attribute);
247+
}
248+
}
239249
}
240250

241251
try {
@@ -300,6 +310,26 @@ public function execute()
300310
return $resultRedirect;
301311
}
302312

313+
/**
314+
* Convert comma-separated list of attributes to delete into array
315+
*
316+
* @param string $attribute
317+
* @return array
318+
*/
319+
private function prepareAttributesToDelete(string $attribute) : array
320+
{
321+
$result = [];
322+
if ($attribute !== "") {
323+
if (str_contains($attribute, ',')) {
324+
$result = explode(',', $attribute);
325+
} else {
326+
$result[] = $attribute;
327+
}
328+
$result = array_unique($result);
329+
}
330+
return $result;
331+
}
332+
303333
/**
304334
* Adds a complex success message if email confirmation is required
305335
*
@@ -468,11 +498,7 @@ private function deleteCustomerFileAttribute(
468498
string $attributeToDelete
469499
) : void {
470500
if ($attributeToDelete !== '') {
471-
if (strpos($attributeToDelete, ',') !== false) {
472-
$attributes = explode(',', $attributeToDelete);
473-
} else {
474-
$attributes[] = $attributeToDelete;
475-
}
501+
$attributes = $this->prepareAttributesToDelete($attributeToDelete);
476502
foreach ($attributes as $attr) {
477503
$attributeValue = $customerCandidateDataObject->getCustomAttribute($attr);
478504
if ($attributeValue!== null) {

0 commit comments

Comments
 (0)