Skip to content

Commit 964f7b0

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.1-develop
Accepted Public Pull Requests: - #17613: [Backport] Added template as argument to the store address renderer to allow custom formatting (by @TomashKhamlai) - #17609: [Backport] 6305 - Resolved product custom option title save issue (by @jignesh-baldha) Fixed GitHub Issues: - #6305: Can't save Customizable options (reported by @bachlee89) has been fixed in #17609 by @jignesh-baldha in 2.1-develop branch Related commits: 1. cd9ba04 2. 1bcd7dc 3. 0a16848 4. 470320e
2 parents 87f0927 + 684fe93 commit 964f7b0

File tree

7 files changed

+27
-10
lines changed

7 files changed

+27
-10
lines changed

app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ protected function isValidOptionTitle($title, $storeId)
106106
if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $title === null) {
107107
return true;
108108
}
109-
if ($this->isEmpty($title)) {
109+
110+
// checking whether title is null and is empty string
111+
if ($title === null || $title === '') {
110112
return false;
111113
}
112114

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ protected function _saveValueTitles(AbstractModel $object)
256256
$object->unsetData('title');
257257
}
258258

259-
if ($object->getTitle()) {
259+
/*** Checking whether title is not null ***/
260+
if ($object->getTitle()!= null) {
260261
if ($existInCurrentStore) {
261262
if ($storeId == $object->getStoreId()) {
262263
$where = [

app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public function draw()
127127
'feed' => 35,
128128
];
129129

130-
if ($option['value']) {
130+
// Checking whether option value is not null
131+
if ($option['value']!= null) {
131132
if (isset($option['print_value'])) {
132133
$printValue = $option['print_value'];
133134
} else {

app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function draw()
8989
];
9090

9191
// draw options value
92-
if ($option['value']) {
92+
if ($option['value']!= null) {
9393
$printValue = isset(
9494
$option['print_value']
9595
) ? $option['print_value'] : $this->filterManager->stripTags(

app/code/Magento/Store/Model/Address/Renderer.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
*/
1616
class Renderer
1717
{
18+
const DEFAULT_TEMPLATE = "{{var name}}\n" .
19+
"{{var street_line1}}\n" .
20+
"{{depend street_line2}}{{var street_line2}}\n{{/depend}}" .
21+
"{{depend city}}{{var city}},{{/depend}} {{var region}} {{depend postcode}}{{var postcode}},{{/depend}}\n" .
22+
"{{var country}}";
23+
1824
/**
1925
* @var EventManager
2026
*/
@@ -25,18 +31,26 @@ class Renderer
2531
*/
2632
protected $filterManager;
2733

34+
/**
35+
* @var string
36+
*/
37+
private $template;
38+
2839
/**
2940
* Constructor
3041
*
3142
* @param EventManager $eventManager
3243
* @param FilterManager $filterManager
44+
* @param string $template
3345
*/
3446
public function __construct(
3547
EventManager $eventManager,
36-
FilterManager $filterManager
48+
FilterManager $filterManager,
49+
$template = self::DEFAULT_TEMPLATE
3750
) {
3851
$this->eventManager = $eventManager;
3952
$this->filterManager = $filterManager;
53+
$this->template = $template;
4054
}
4155

4256
/**
@@ -50,8 +64,7 @@ public function format(DataObject $storeInfo, $type = 'html')
5064
{
5165
$this->eventManager->dispatch('store_address_format', ['type' => $type, 'store_info' => $storeInfo]);
5266
$address = $this->filterManager->template(
53-
"{{var name}}\n{{var street_line1}}\n{{depend street_line2}}{{var street_line2}}\n{{/depend}}"
54-
. "{{var city}}, {{var region}} {{var postcode}},\n{{var country}}",
67+
$this->template,
5568
['variables' => $storeInfo->getData()]
5669
);
5770

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function testAddNegative($optionData)
220220
];
221221

222222
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
223-
if (isset($optionDataPost['title']) && empty($optionDataPost['title'])) {
223+
if ($optionDataPost['title'] === null || $optionDataPost['title'] === '') {
224224
$this->setExpectedException('SoapFault', 'Missed values for option required fields');
225225
} else {
226226
$this->setExpectedException('SoapFault', 'Invalid option');

dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_negative.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
return [
88
'empty_required_field' => [
9-
'title' => '',
9+
'title' => null,
1010
'type' => 'field',
1111
'sort_order' => 1,
1212
'is_require' => 1,
@@ -54,7 +54,7 @@
5454
'price' => 10.0,
5555
'price_type' => 'fixed',
5656
'sku' => 'radio option 1 sku',
57-
'title' => '',
57+
'title' => null,
5858
'sort_order' => 1,
5959
],
6060
],

0 commit comments

Comments
 (0)