Skip to content

Commit c9c8f80

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into MAGETWO-48544
2 parents e035365 + 9368ecf commit c9c8f80

File tree

70 files changed

+1426
-316
lines changed

Some content is hidden

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

70 files changed

+1426
-316
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ Tests:
28682868
* Fixed a 404 error after saving mass update product attributes form
28692869
* Fixed an issue when it was impossible to perform search by all tax classes on the Advanced Search page
28702870
* Fixed an issue when attribute order for configurable product was not preserved after saving product
2871-
* Fixed an issue with no results for the Product Best Sellers report
2871+
* Fixed an issue with no results for the Product Bestsellers report
28722872
* Fixed a fatal error when opening tax configuration page in the backend
28732873
* Fixed an error occurring when opening the Tax Zones and Rates page in the backend
28742874
* Fixed a 404 error occurring while searching products on the New Review page

app/code/Magento/Customer/Block/Widget/Dob.php

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

88
use Magento\Customer\Api\CustomerMetadataInterface;
99
use Magento\Framework\Api\ArrayObjectSearch;
10-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1110

1211
/**
1312
* Class Dob
@@ -35,21 +34,29 @@ class Dob extends AbstractWidget
3534
*/
3635
protected $dateElement;
3736

37+
/**
38+
* @var \Magento\Framework\Data\Form\FilterFactory
39+
*/
40+
protected $filterFactory;
41+
3842
/**
3943
* @param \Magento\Framework\View\Element\Template\Context $context
4044
* @param \Magento\Customer\Helper\Address $addressHelper
4145
* @param CustomerMetadataInterface $customerMetadata
4246
* @param \Magento\Framework\View\Element\Html\Date $dateElement
47+
* @param \Magento\Framework\Data\Form\FilterFactory $filterFactory
4348
* @param array $data
4449
*/
4550
public function __construct(
4651
\Magento\Framework\View\Element\Template\Context $context,
4752
\Magento\Customer\Helper\Address $addressHelper,
4853
CustomerMetadataInterface $customerMetadata,
4954
\Magento\Framework\View\Element\Html\Date $dateElement,
55+
\Magento\Framework\Data\Form\FilterFactory $filterFactory,
5056
array $data = []
5157
) {
5258
$this->dateElement = $dateElement;
59+
$this->filterFactory = $filterFactory;
5360
parent::__construct($context, $addressHelper, $customerMetadata, $data);
5461
}
5562

@@ -87,10 +94,45 @@ public function isRequired()
8794
public function setDate($date)
8895
{
8996
$this->setTime($date ? strtotime($date) : false);
90-
$this->setData('date', $date);
97+
$this->setValue($this->applyOutputFilter($date));
9198
return $this;
9299
}
93100

101+
/**
102+
* Return Data Form Filter or false
103+
*
104+
* @return \Magento\Framework\Data\Form\Filter\FilterInterface|false
105+
*/
106+
protected function getFormFilter()
107+
{
108+
$attributeMetadata = $this->_getAttribute('dob');
109+
$filterCode = $attributeMetadata->getInputFilter();
110+
if ($filterCode) {
111+
$data = [];
112+
if ($filterCode == 'date') {
113+
$data['format'] = $this->getDateFormat();
114+
}
115+
$filter = $this->filterFactory->create($filterCode, $data);
116+
return $filter;
117+
}
118+
return false;
119+
}
120+
121+
/**
122+
* Apply output filter to value
123+
*
124+
* @param string $value
125+
* @return string
126+
*/
127+
protected function applyOutputFilter($value)
128+
{
129+
$filter = $this->getFormFilter();
130+
if ($filter) {
131+
$value = $filter->outputFilter($value);
132+
}
133+
return $value;
134+
}
135+
94136
/**
95137
* @return string|bool
96138
*/

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\Action\Context;
1212
use Magento\Customer\Model\Session;
1313
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\Exception\LocalizedException;
1415
use Magento\Store\Model\StoreManagerInterface;
1516
use Magento\Customer\Api\AccountManagementInterface;
1617
use Magento\Customer\Helper\Address;
@@ -274,6 +275,8 @@ public function execute()
274275
foreach ($e->getErrors() as $error) {
275276
$this->messageManager->addError($this->escaper->escapeHtml($error->getMessage()));
276277
}
278+
} catch (LocalizedException $e) {
279+
$this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
277280
} catch (\Exception $e) {
278281
$this->messageManager->addException($e, __('We can\'t save the customer.'));
279282
}

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Customer\Model\Session;
1414
use Magento\Framework\App\Action\Context;
1515
use Magento\Framework\Exception\AuthenticationException;
16-
use Magento\Framework\Exception\InputException;
16+
use Magento\Framework\Exception\LocalizedException;
1717

1818
/**
1919
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -93,15 +93,10 @@ public function execute()
9393

9494
try {
9595
$this->customerRepository->save($customer);
96-
} catch (AuthenticationException $e) {
96+
} catch (LocalizedException $e) {
9797
$this->messageManager->addError($e->getMessage());
98-
} catch (InputException $e) {
99-
$this->messageManager->addException($e, __('Invalid input'));
10098
} catch (\Exception $e) {
101-
$message = __('We can\'t save the customer.')
102-
. $e->getMessage()
103-
. '<pre>' . $e->getTraceAsString() . '</pre>';
104-
$this->messageManager->addException($e, $message);
99+
$this->messageManager->addException($e, __('We can\'t save the customer.'));
105100
}
106101

107102
if ($this->messageManager->getMessages()->getCount() > 0) {

app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ class DobTest extends \PHPUnit_Framework_TestCase
4343
'<div><label for="year"><span>yy</span></label><input type="text" id="year" name="Year" value="14"></div>';
4444

4545
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Api\Data\AttributeMetadataInterface */
46-
private $attribute;
46+
protected $attribute;
4747

4848
/** @var Dob */
49-
private $_block;
49+
protected $_block;
5050

5151
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Api\CustomerMetadataInterface */
52-
private $customerMetadata;
52+
protected $customerMetadata;
53+
54+
/**
55+
* @var \Magento\Framework\Data\Form\FilterFactory|\PHPUnit_Framework_MockObject_MockObject
56+
*/
57+
protected $filterFactory;
5358

5459
public function setUp()
5560
{
@@ -89,11 +94,16 @@ public function setUp()
8994

9095
date_default_timezone_set('America/Los_Angeles');
9196

97+
$this->filterFactory = $this->getMockBuilder('Magento\Framework\Data\Form\FilterFactory')
98+
->disableOriginalConstructor()
99+
->getMock();
100+
92101
$this->_block = new \Magento\Customer\Block\Widget\Dob(
93102
$context,
94103
$this->getMock('Magento\Customer\Helper\Address', [], [], '', false),
95104
$this->customerMetadata,
96-
$this->getMock('Magento\Framework\View\Element\Html\Date', [], [], '', false)
105+
$this->getMock('Magento\Framework\View\Element\Html\Date', [], [], '', false),
106+
$this->filterFactory
97107
);
98108
}
99109

@@ -178,7 +188,7 @@ public function testSetDate($date, $expectedTime, $expectedDate)
178188
{
179189
$this->assertSame($this->_block, $this->_block->setDate($date));
180190
$this->assertEquals($expectedTime, $this->_block->getTime());
181-
$this->assertEquals($expectedDate, $this->_block->getData('date'));
191+
$this->assertEquals($expectedDate, $this->_block->getValue());
182192
}
183193

184194
/**
@@ -189,6 +199,31 @@ public function setDateDataProvider()
189199
return [[self::DATE, strtotime(self::DATE), self::DATE], [false, false, false]];
190200
}
191201

202+
public function testSetDateWithFilter()
203+
{
204+
$date = '2014-01-01';
205+
$filterCode = 'date';
206+
207+
$this->attribute->expects($this->once())
208+
->method('getInputFilter')
209+
->willReturn($filterCode);
210+
211+
$filterMock = $this->getMockBuilder('Magento\Framework\Data\Form\Filter\Date')
212+
->disableOriginalConstructor()
213+
->getMock();
214+
$filterMock->expects($this->once())
215+
->method('outputFilter')
216+
->with($date)
217+
->willReturn(self::DATE);
218+
219+
$this->filterFactory->expects($this->once())
220+
->method('create')
221+
->with($filterCode, ['format' => self::DATE_FORMAT])
222+
->willReturn($filterMock);
223+
224+
$this->_block->setDate($date);
225+
}
226+
192227
/**
193228
* @param string|bool $date The date (e.g. '01/01/2020' or false for no date)
194229
* @param string $expectedDay The value we expect from Dob::getDay()

app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,8 @@ public function exceptionDataProvider()
454454
return [
455455
[
456456
'counter' => 1,
457-
'message' => 'AuthenticationException',
458-
'exception' => '\Magento\Framework\Exception\AuthenticationException',
459-
],
460-
[
461-
'counter' => 1,
462-
'message' => 'InputException',
463-
'exception' => '\Magento\Framework\Exception\InputException',
457+
'message' => 'LocalizedException',
458+
'exception' => '\Magento\Framework\Exception\LocalizedException',
464459
],
465460
[
466461
'counter' => 1,

app/code/Magento/Customer/view/base/ui_component/customer_form.xml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -343,41 +343,6 @@
343343
</item>
344344
</argument>
345345
</field>
346-
<container name="street_container">
347-
<argument name="data" xsi:type="array">
348-
<item name="type" xsi:type="string">group</item>
349-
<item name="config" xsi:type="array">
350-
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
351-
<item name="label" xsi:type="string" translate="true">Street Address</item>
352-
<item name="required" xsi:type="boolean">true</item>
353-
<item name="dataScope" xsi:type="string">street</item>
354-
<item name="sortOrder" xsi:type="string">45</item>
355-
</item>
356-
</argument>
357-
<field name="street">
358-
<argument name="data" xsi:type="array">
359-
<item name="config" xsi:type="array">
360-
<item name="dataScope" xsi:type="string">0</item>
361-
<item name="dataType" xsi:type="string">text</item>
362-
<item name="formElement" xsi:type="string">input</item>
363-
<item name="source" xsi:type="string">address</item>
364-
<item name="validation" xsi:type="array">
365-
<item name="required-entry" xsi:type="boolean">true</item>
366-
</item>
367-
</item>
368-
</argument>
369-
</field>
370-
<field name="street_second">
371-
<argument name="data" xsi:type="array">
372-
<item name="config" xsi:type="array">
373-
<item name="dataScope" xsi:type="string">1</item>
374-
<item name="dataType" xsi:type="string">text</item>
375-
<item name="formElement" xsi:type="string">input</item>
376-
<item name="source" xsi:type="string">address</item>
377-
</item>
378-
</argument>
379-
</field>
380-
</container>
381346
<field name="city">
382347
<argument name="data" xsi:type="array">
383348
<item name="config" xsi:type="array">

app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Bestsellers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class Bestsellers extends \Magento\Reports\Controller\Adminhtml\Report\Sales
1212
{
1313
/**
14-
* Best sellers report action
14+
* Bestsellers report action
1515
*
1616
* @return void
1717
*/
@@ -25,7 +25,7 @@ public function execute()
2525
__('Products Bestsellers Report'),
2626
__('Products Bestsellers Report')
2727
);
28-
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Best Sellers Report'));
28+
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Bestsellers Report'));
2929

3030
$gridBlock = $this->_view->getLayout()->getBlock('adminhtml_sales_bestsellers.grid');
3131
$filterFormBlock = $this->_view->getLayout()->getBlock('grid.filter.form');

app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Sales.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function execute()
2525
__('Sales Report'),
2626
__('Sales Report')
2727
);
28-
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Sales Report'));
28+
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Orders Report'));
2929

3030
$gridBlock = $this->_view->getLayout()->getBlock('adminhtml_sales_sales.grid');
3131
$filterFormBlock = $this->_view->getLayout()->getBlock('grid.filter.form');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Reviews,Reviews
147147
"Customers Report","Customers Report"
148148
"Product Reviews Report","Product Reviews Report"
149149
"Sales Report","Sales Report"
150-
"Best Sellers Report","Best Sellers Report"
150+
"Bestsellers Report","Bestsellers Report"
151151
"Tax Report","Tax Report"
152152
"Shipping Report","Shipping Report"
153153
"Invoice Report","Invoice Report"

app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Rule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
*/
66
namespace Magento\SalesRule\Model\Plugin\ResourceModel;
77

8+
/**
9+
* Class Rule
10+
* @package Magento\SalesRule\Model\Plugin\ResourceModel
11+
* @deprecated
12+
*/
813
class Rule
914
{
1015
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\SalesRule\Model\ResourceModel;
7+
8+
use Magento\SalesRule\Model\ResourceModel\Rule;
9+
use Magento\Framework\Model\Entity\MetadataPool;
10+
11+
class ReadHandler
12+
{
13+
/**
14+
* @var Rule
15+
*/
16+
protected $ruleResource;
17+
18+
/**
19+
* @var MetadataPool
20+
*/
21+
protected $metadataPool;
22+
23+
/**
24+
* @param Rule $ruleResource
25+
* @param MetadataPool $metadataPool
26+
*/
27+
public function __construct(
28+
Rule $ruleResource,
29+
MetadataPool $metadataPool
30+
) {
31+
$this->ruleResource = $ruleResource;
32+
$this->metadataPool = $metadataPool;
33+
}
34+
35+
/**
36+
* @param string $entityType
37+
* @param array $entityData
38+
* @return array
39+
* @throws \Exception
40+
*/
41+
public function execute($entityType, $entityData)
42+
{
43+
$linkField = $this->metadataPool->getMetadata($entityType)->getLinkField();
44+
$entityId = $entityData[$linkField];
45+
46+
$entityData['customer_group_ids'] = $this->ruleResource->getCustomerGroupIds($entityId);
47+
$entityData['website_ids'] = $this->ruleResource->getWebsiteIds($entityId);
48+
49+
return $entityData;
50+
}
51+
}

0 commit comments

Comments
 (0)