Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 3e4259a

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1851 from magento-engcom/2.2-develop-prs
Public Pull Requests - magento/magento2#11563 Add price calculation improvement for product option value price by @marinagociu - magento-engcom#1024 [Backport] magento/magento2#10734: Magento 2 is not showing Popular Search Terms by @p-bystritsky - magento-engcom#1023 magento/magento2#12667: Incorrect partial attribute (EAV) reindex (Update by Schedule) for configurable product with childs visibility "Not Visible Individually" by @RomaKis - magento-engcom#1017 magento/magento2#12084: Product csv import > fail on round brackets in image filename by @p-bystritsky - magento-engcom#1021 magento/magento2#12656: Checkout: Whitespace in front of coupon code causes "Coupon code is not valid" by @RomaKis - magento/magento2#12666 Fix incorrect DHL Product codes by @gwharton Fixed Public Issues - magento/magento2#5774 Tier price and custom options give bad results - magento/magento2#10743 Magento 2 is not showing Popular Search Terms - magento/magento2#12667 Incorrect partial attribute (EAV) reindex (Update by Schedule) for configurable product with childs visibility "Not Visible Individually" - magento/magento2#12084 Product csv import > fail on round brackets in image filename - magento/magento2#12656 Checkout: Whitespace in front of coupon code causes "Coupon code is not valid"
2 parents 3839c0f + ee857ea commit 3e4259a

File tree

18 files changed

+346
-19
lines changed

18 files changed

+346
-19
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Eav/AbstractAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ protected function syncData($indexer, $destinationTable, $ids)
143143
protected function processRelations($indexer, $ids, $onlyParents = false)
144144
{
145145
$parentIds = $indexer->getRelationsByChild($ids);
146+
$parentIds = array_unique(array_merge($parentIds, $ids));
146147
$childIds = $onlyParents ? [] : $indexer->getRelationsByParent($parentIds);
147148
return array_unique(array_merge($ids, $childIds, $parentIds));
148149
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Model\Product;
1212
use Magento\Catalog\Model\Product\Option;
1313
use Magento\Framework\Model\AbstractModel;
14+
use Magento\Catalog\Pricing\Price\BasePrice;
1415

1516
/**
1617
* Catalog product option select type model
@@ -224,7 +225,7 @@ public function saveValues()
224225
public function getPrice($flag = false)
225226
{
226227
if ($flag && $this->getPriceType() == self::TYPE_PERCENT) {
227-
$basePrice = $this->getOption()->getProduct()->getFinalPrice();
228+
$basePrice = $this->getOption()->getProduct()->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getValue();
228229
$price = $basePrice * ($this->_getData(self::KEY_PRICE) / 100);
229230
return $price;
230231
}

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ public function testReindexWithNotNullArgumentExecutesReindexEntities()
129129
->disableOriginalConstructor()
130130
->getMock();
131131

132-
$eavSource->expects($this->once())->method('getRelationsByChild')->with($childIds)->willReturn($childIds);
133-
$eavSource->expects($this->once())->method('getRelationsByParent')->with($childIds)->willReturn($parentIds);
132+
$eavSource->expects($this->once())->method('getRelationsByChild')->with($childIds)->willReturn($parentIds);
133+
$eavSource->expects($this->once())->method('getRelationsByParent')
134+
->with(array_unique(array_merge($parentIds, $childIds)))->willReturn($parentIds);
134135

135136
$eavDecimal->expects($this->once())->method('getRelationsByChild')->with($reindexIds)->willReturn($reindexIds);
136137
$eavDecimal->expects($this->once())->method('getRelationsByParent')->with($reindexIds)->willReturn([]);

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,27 @@ private function getMockedOption()
164164
private function getMockedProduct()
165165
{
166166
$mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
167-
->setMethods(['getFinalPrice', '__wakeup'])
167+
->setMethods(['getPriceInfo', '__wakeup'])
168168
->disableOriginalConstructor();
169169
$mock = $mockBuilder->getMock();
170170

171-
$mock->expects($this->any())
172-
->method('getFinalPrice')
173-
->will($this->returnValue(10));
171+
$priceInfoMock = $this->getMockForAbstractClass(
172+
\Magento\Framework\Pricing\PriceInfoInterface::class,
173+
[],
174+
'',
175+
false,
176+
false,
177+
true,
178+
['getPrice']
179+
);
180+
181+
$priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class);
182+
183+
$priceInfoMock->expects($this->any())->method('getPrice')->willReturn($priceMock);
184+
185+
$mock->expects($this->any())->method('getPriceInfo')->willReturn($priceInfoMock);
186+
187+
$priceMock->expects($this->any())->method('getValue')->willReturn(10);
174188

175189
return $mock;
176190
}

app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Media extends AbstractImportValidator implements RowValidatorInterface
1717
*/
1818
const URL_REGEXP = '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i';
1919

20-
const PATH_REGEXP = '#^(?!.*[\\/]\.{2}[\\/])(?!\.{2}[\\/])[-\w.\\/]+$#';
20+
const PATH_REGEXP = '#^(?!.*[\\/]\.{2}[\\/])(?!\.{2}[\\/])[-\w.\\/()]+$#';
2121

2222
const ADDITIONAL_IMAGES = 'additional_images';
2323

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ public function getDhlProducts($doc)
606606
'L' => __('Express 10:30'),
607607
'G' => __('Domestic economy select'),
608608
'W' => __('Economy select'),
609-
'I' => __('Break bulk economy'),
609+
'I' => __('Domestic express 9:00'),
610610
'N' => __('Domestic express'),
611611
'O' => __('Others'),
612612
'R' => __('Globalmail business'),
@@ -616,7 +616,7 @@ public function getDhlProducts($doc)
616616
];
617617

618618
$nonDocType = [
619-
'1' => __('Customer services'),
619+
'1' => __('Domestic express 12:00'),
620620
'3' => __('Easy shop'),
621621
'4' => __('Jetline'),
622622
'8' => __('Express easy'),

app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,67 @@ public function requestToShipmentDataProvider()
447447
]
448448
];
449449
}
450+
451+
/**
452+
* @dataProvider dhlProductsDataProvider
453+
*
454+
* @param string $docType
455+
* @param array $products
456+
*/
457+
public function testGetDhlProducts(string $docType, array $products)
458+
{
459+
$this->assertEquals($products, $this->model->getDhlProducts($docType));
460+
}
461+
462+
/**
463+
* @return array
464+
*/
465+
public function dhlProductsDataProvider() : array
466+
{
467+
return [
468+
'doc' => [
469+
'docType' => \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_DOC,
470+
'products' => [
471+
'2' => 'Easy shop',
472+
'5' => 'Sprintline',
473+
'6' => 'Secureline',
474+
'7' => 'Express easy',
475+
'9' => 'Europack',
476+
'B' => 'Break bulk express',
477+
'C' => 'Medical express',
478+
'D' => 'Express worldwide',
479+
'U' => 'Express worldwide',
480+
'K' => 'Express 9:00',
481+
'L' => 'Express 10:30',
482+
'G' => 'Domestic economy select',
483+
'W' => 'Economy select',
484+
'I' => 'Domestic express 9:00',
485+
'N' => 'Domestic express',
486+
'O' => 'Others',
487+
'R' => 'Globalmail business',
488+
'S' => 'Same day',
489+
'T' => 'Express 12:00',
490+
'X' => 'Express envelope',
491+
]
492+
],
493+
'non-doc' => [
494+
'docType' => \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_NON_DOC,
495+
'products' => [
496+
'1' => 'Domestic express 12:00',
497+
'3' => 'Easy shop',
498+
'4' => 'Jetline',
499+
'8' => 'Express easy',
500+
'P' => 'Express worldwide',
501+
'Q' => 'Medical express',
502+
'E' => 'Express 9:00',
503+
'F' => 'Freight worldwide',
504+
'H' => 'Economy select',
505+
'J' => 'Jumbo box',
506+
'M' => 'Express 10:30',
507+
'V' => 'Europack',
508+
'Y' => 'Express 12:00',
509+
]
510+
]
511+
];
512+
}
450513
}

app/code/Magento/Dhl/i18n/en_US.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ Europack,Europack
2323
"Express 10:30","Express 10:30"
2424
"Domestic economy select","Domestic economy select"
2525
"Economy select","Economy select"
26-
"Break bulk economy","Break bulk economy"
2726
"Domestic express","Domestic express"
2827
Others,Others
2928
"Globalmail business","Globalmail business"
3029
"Same day","Same day"
3130
"Express 12:00","Express 12:00"
3231
"Express envelope","Express envelope"
33-
"Customer services","Customer services"
3432
Jetline,Jetline
3533
"Freight worldwide","Freight worldwide"
3634
"Jumbo box","Jumbo box"
@@ -81,3 +79,5 @@ Size,Size
8179
"Show Method if Not Applicable","Show Method if Not Applicable"
8280
"Sort Order","Sort Order"
8381
Debug,Debug
82+
"Domestic express 9:00","Domestic express 9:00"
83+
"Domestic express 12:00","Domestic express 12:00"

app/code/Magento/Quote/Model/CouponManagement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function get($cartId)
5050
*/
5151
public function set($cartId, $couponCode)
5252
{
53+
$couponCode = trim($couponCode);
5354
/** @var \Magento\Quote\Model\Quote $quote */
5455
$quote = $this->quoteRepository->getActive($cartId);
5556
if (!$quote->getItemsCount()) {

app/code/Magento/Search/Block/Term.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ protected function _loadTerms()
9595
continue;
9696
}
9797
$term->setRatio(($term->getPopularity() - $this->_minPopularity) / $range);
98-
$temp[$term->getName()] = $term;
99-
$termKeys[] = $term->getName();
98+
$temp[$term->getData('query_text')] = $term;
99+
$termKeys[] = $term->getData('query_text');
100100
}
101101
natcasesort($termKeys);
102102

@@ -128,7 +128,7 @@ public function getSearchUrl($obj)
128128
* url encoding will be done in Url.php http_build_query
129129
* so no need to explicitly called urlencode for the text
130130
*/
131-
$url->setQueryParam('q', $obj->getName());
131+
$url->setQueryParam('q', $obj->getData('query_text'));
132132
return $url->getUrl('catalogsearch/result');
133133
}
134134

app/code/Magento/Search/view/frontend/templates/term.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<li class="item">
1414
<a href="<?= /* @escapeNotVerified */ $block->getSearchUrl($_term) ?>"
1515
style="font-size:<?= /* @escapeNotVerified */ $_term->getRatio()*70+75 ?>%;">
16-
<?= $block->escapeHtml($_term->getName()) ?>
16+
<?= $block->escapeHtml($_term->getData('query_text')) ?>
1717
</a>
1818
</li>
1919
<?php endforeach; ?>

dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,46 @@ public function testSetMyCouponSuccess()
297297

298298
$this->assertEquals($quoteWithCoupon->getCouponCode(), $couponCode);
299299
}
300+
301+
/**
302+
* @magentoApiDataFixture Magento/Sales/_files/quote.php
303+
* @magentoApiDataFixture Magento/Checkout/_files/discount_10percent.php
304+
*/
305+
public function testSetCouponWihSpaces()
306+
{
307+
/** @var \Magento\Quote\Model\Quote $quote */
308+
$quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class);
309+
$quote->load('test01', 'reserved_order_id');
310+
$cartId = $quote->getId();
311+
/** @var \Magento\SalesRule\Model\Rule $salesRule */
312+
$salesRule = $this->objectManager->create(\Magento\SalesRule\Model\Rule::class);
313+
$salesRuleId = $this->objectManager->get(\Magento\Framework\Registry::class)
314+
->registry('Magento/Checkout/_file/discount_10percent');
315+
$salesRule->load($salesRuleId);
316+
$couponCode = $salesRule->getPrimaryCoupon()->getCode() ;
317+
$serviceInfo = [
318+
'rest' => [
319+
'resourcePath' => self::RESOURCE_PATH . $cartId . '/coupons/'
320+
. rawurlencode(' ') . $couponCode . rawurlencode(' '),
321+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT,
322+
],
323+
'soap' => [
324+
'service' => self::SERVICE_NAME,
325+
'serviceVersion' => self::SERVICE_VERSION,
326+
'operation' => self::SERVICE_NAME . 'Set',
327+
],
328+
];
329+
330+
$requestData = [
331+
"cartId" => $cartId,
332+
"couponCode" => $couponCode,
333+
];
334+
335+
$this->assertTrue($this->_webApiCall($serviceInfo, $requestData));
336+
337+
$quoteWithCoupon = $this->objectManager->create(\Magento\Quote\Model\Quote::class);
338+
$quoteWithCoupon->load('test01', 'reserved_order_id');
339+
340+
$this->assertEquals($quoteWithCoupon->getCouponCode(), $couponCode);
341+
}
300342
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label1,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,crosssell_skus,upsell_skus,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,associated_skus
2-
simple_new,,Default,simple,,base,New Product,,,,1,Taxable Goods,"Catalog, Search",10,,,,new-product,New Product,New Product,New Product ,magento_image.jpg,Image Label,magento_small_image.jpg,Small Image Label,magento_thumbnail.jpg,Thumbnail Label,magento_image.jpg,Image Label,10/20/15 07:05,10/20/15 07:05,,,Block after Info Column,,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100,0,1,0,0,1,1,1,10000,1,1,1,1,1,0,1,1,0,0,0,1,,,,"magento_additional_image_one.jpg, magento_additional_image_two.jpg","Additional Image Label One,Additional Image Label Two",,,,,,,,
2+
simple_new,,Default,simple,,base,New Product,,,,1,Taxable Goods,"Catalog, Search",10,,,,new-product,New Product,New Product,New Product ,magento_image(1).jpg,Image Label,magento_small_image.jpg,Small Image Label,magento_thumbnail.jpg,Thumbnail Label,magento_image(1).jpg,Image Label,10/20/15 07:05,10/20/15 07:05,,,Block after Info Column,,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100,0,1,0,0,1,1,1,10000,1,1,1,1,1,0,1,1,0,0,0,1,,,,"magento_additional_image_one.jpg, magento_additional_image_two.jpg","Additional Image Label One,Additional Image Label Two",,,,,,,,

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
$items = [
2121
[
2222
'source' => __DIR__ . '/../../../../../Magento/Catalog/_files/magento_image.jpg',
23-
'dest' => $dirPath . '/magento_image.jpg',
23+
'dest' => $dirPath . '/magento_image(1).jpg',
2424
],
2525
[
2626
'source' => __DIR__ . '/../../../../../Magento/Catalog/_files/magento_small_image.jpg',

dev/tests/integration/testsuite/Magento/CatalogSearch/Block/TermTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp()
2424
public function testGetSearchUrl()
2525
{
2626
$query = uniqid();
27-
$obj = new \Magento\Framework\DataObject(['name' => $query]);
27+
$obj = new \Magento\Framework\DataObject(['query_text' => $query]);
2828
$this->assertStringEndsWith("/catalogsearch/result/?q={$query}", $this->_block->getSearchUrl($obj));
2929
}
3030
}

0 commit comments

Comments
 (0)