Skip to content

Commit 00c6b48

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #15322: ISSUE-11477 - fixed Swagger response for searchCriteria (by @idziakjakub) - #15320: issue/14056 - Coupon API not working for guest user (by @Hypo386) - #12626: Fixed condition with usage "hack" isPostRequest method (by @pusachev) - #15661: Fixed Wrong order amount on dashboard on Last orders listing when having more than one website with different currencies (by @ankurvr) - #15689: #15588 Fixed incorrect image urls in multistore xml sitemap (by @StevenGuapaBV) - #15826: Add missing table aliases to fields mapping for Customer Group filter� (by @radio) - #12935: Add Ability To Separate Frontend / Adminhtml in New Relic (by @mpchadwick) - #15019: [TASK] Solve issue #14966 - Disabling product does not remove it from� (by @lewisvoncken) - #15297: Fix typo in test method's name and test result (by @dmytro-ch) Fixed GitHub Issues: - #11477: Magento REST API Schema (Swagger) is not compatible with Search Criteria (reported by @careys7) has been fixed in #15322 by @idziakjakub in 2.2-develop branch Related commits: 1. 788485a - #14056: Coupon API not working for guest user (reported by @gnanasekaranl) has been fixed in #15320 by @Hypo386 in 2.2-develop branch Related commits: 1. 6ad9c03 2. 8b7bb58 - #15660: Wrong order amount on dashboard on Last orders listing when having more than one website with different currencies (reported by @ankurvr) has been fixed in #15661 by @ankurvr in 2.2-develop branch Related commits: 1. 56bcffb 2. 1c1e277 - #15588: Images in XML sitemap are always linked to base store in multistore (reported by @dvershinin) has been fixed in #15689 by @StevenGuapaBV in 2.2-develop branch Related commits: 1. 7b8fe3d 2. 498047c 3. 63ed864 4. 83ad777 5. 6a490a8 6. f1dd4e8 7. b7f8d28 - #15822: SQL Error: ambiguous column 'customer_group_id' in 'All customers' page in admin when extension attribute table is joined (reported by @radio) has been fixed in #15826 by @radio in 2.2-develop branch Related commits: 1. 83a8dea - #14966: Disabling product does not remove it from the flat index (reported by @ktruehl) has been fixed in #15019 by @lewisvoncken in 2.2-develop branch Related commits: 1. 0d35081 2. c6196d7 3. 2d6fb62 4. 38bd9d3 5. 219024c
2 parents 0d9a4e3 + 6d1ac43 commit 00c6b48

File tree

22 files changed

+370
-40
lines changed

22 files changed

+370
-40
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ public function __construct(
6868
$this->_storeManager = $storeManager;
6969
$this->_currencyLocator = $currencyLocator;
7070
$this->_localeCurrency = $localeCurrency;
71-
$defaultBaseCurrencyCode = $this->_scopeConfig->getValue(
72-
\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
73-
'default'
74-
);
71+
$defaultBaseCurrencyCode = $currencyLocator->getDefaultCurrency($this->_request);
7572
$this->_defaultBaseCurrency = $currencyFactory->create()->load($defaultBaseCurrencyCode);
7673
}
7774

app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function __construct(
6161
* @param int|null $id
6262
* @return \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row
6363
* @throws \Magento\Framework\Exception\LocalizedException
64+
* @throws \Zend_Db_Statement_Exception
6465
*/
6566
public function execute($id = null)
6667
{
@@ -75,17 +76,43 @@ public function execute($id = null)
7576
if ($tableExists) {
7677
$this->flatItemEraser->removeDeletedProducts($ids, $store->getId());
7778
}
78-
if (isset($ids[0])) {
79-
if (!$tableExists) {
80-
$this->_flatTableBuilder->build(
81-
$store->getId(),
82-
[$ids[0]],
83-
$this->_valueFieldSuffix,
84-
$this->_tableDropSuffix,
85-
false
86-
);
79+
80+
/* @var $status \Magento\Eav\Model\Entity\Attribute */
81+
$status = $this->_productIndexerHelper->getAttribute('status');
82+
$statusTable = $status->getBackend()->getTable();
83+
$statusConditions = [
84+
'store_id IN(0,' . (int)$store->getId() . ')',
85+
'attribute_id = ' . (int)$status->getId(),
86+
'entity_id = ' . (int)$id
87+
];
88+
$select = $this->_connection->select();
89+
$select->from(
90+
$statusTable,
91+
['value']
92+
)->where(
93+
implode(' AND ', $statusConditions)
94+
)->order(
95+
'store_id DESC'
96+
);
97+
$result = $this->_connection->query($select);
98+
$status = $result->fetch(1);
99+
100+
if ($status['value'] == \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) {
101+
if (isset($ids[0])) {
102+
if (!$tableExists) {
103+
$this->_flatTableBuilder->build(
104+
$store->getId(),
105+
[$ids[0]],
106+
$this->_valueFieldSuffix,
107+
$this->_tableDropSuffix,
108+
false
109+
);
110+
}
111+
$this->flatItemWriter->write($store->getId(), $ids[0], $this->_valueFieldSuffix);
87112
}
88-
$this->flatItemWriter->write($store->getId(), $ids[0], $this->_valueFieldSuffix);
113+
}
114+
if ($status['value'] == \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED) {
115+
$this->flatItemEraser->deleteProductsFromStore($id, $store->getId());
89116
}
90117
}
91118
return $this;

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1212

13+
/**
14+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15+
*/
1316
class RowTest extends \PHPUnit\Framework\TestCase
1417
{
1518
/**
@@ -61,6 +64,8 @@ protected function setUp()
6164
{
6265
$objectManager = new ObjectManager($this);
6366

67+
$attributeTable = 'catalog_product_entity_int';
68+
$statusId = 22;
6469
$this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
6570
$this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
6671
$this->resource->expects($this->any())->method('getConnection')
@@ -70,10 +75,36 @@ protected function setUp()
7075
$this->store = $this->createMock(\Magento\Store\Model\Store::class);
7176
$this->store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1'));
7277
$this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$this->store]));
73-
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
7478
$this->flatItemEraser = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class);
7579
$this->flatItemWriter = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class);
7680
$this->flatTableBuilder = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class);
81+
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
82+
$statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
83+
->disableOriginalConstructor()
84+
->getMock();
85+
$this->productIndexerHelper->expects($this->any())->method('getAttribute')
86+
->with('status')
87+
->willReturn($statusAttributeMock);
88+
$backendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class)
89+
->disableOriginalConstructor()
90+
->getMock();
91+
$backendMock->expects($this->any())->method('getTable')->willReturn($attributeTable);
92+
$statusAttributeMock->expects($this->any())->method('getBackend')->willReturn(
93+
$backendMock
94+
);
95+
$statusAttributeMock->expects($this->any())->method('getId')->willReturn($statusId);
96+
$selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
97+
->disableOriginalConstructor()
98+
->getMock();
99+
$this->connection->expects($this->any())->method('select')->willReturn($selectMock);
100+
$selectMock->expects($this->any())->method('from')->with(
101+
$attributeTable,
102+
['value']
103+
)->willReturnSelf();
104+
$selectMock->expects($this->any())->method('where')->willReturnSelf();
105+
$pdoMock = $this->createMock(\Zend_Db_Statement_Pdo::class);
106+
$this->connection->expects($this->any())->method('query')->with($selectMock)->will($this->returnValue($pdoMock));
107+
$pdoMock->expects($this->any())->method('fetch')->will($this->returnValue(['value' => 1]));
77108

78109
$this->model = $objectManager->getObject(
79110
\Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class, [
@@ -82,7 +113,7 @@ protected function setUp()
82113
'productHelper' => $this->productIndexerHelper,
83114
'flatItemEraser' => $this->flatItemEraser,
84115
'flatItemWriter' => $this->flatItemWriter,
85-
'flatTableBuilder' => $this->flatTableBuilder
116+
'flatTableBuilder' => $this->flatTableBuilder,
86117
]);
87118
}
88119

app/code/Magento/Contact/Controller/Index/Post.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Framework\App\Request\DataPersistorInterface;
1313
use Magento\Framework\Controller\Result\Redirect;
1414
use Magento\Framework\Exception\LocalizedException;
15-
use Magento\Framework\HTTP\PhpEnvironment\Request;
1615
use Psr\Log\LoggerInterface;
1716
use Magento\Framework\App\ObjectManager;
1817
use Magento\Framework\DataObject;
@@ -67,7 +66,7 @@ public function __construct(
6766
*/
6867
public function execute()
6968
{
70-
if (!$this->isPostRequest()) {
69+
if (!$this->getRequest()->isPost()) {
7170
return $this->resultRedirectFactory->create()->setPath('*/*/');
7271
}
7372
try {
@@ -101,16 +100,6 @@ private function sendEmail($post)
101100
);
102101
}
103102

104-
/**
105-
* @return bool
106-
*/
107-
private function isPostRequest()
108-
{
109-
/** @var Request $request */
110-
$request = $this->getRequest();
111-
return !empty($request->getPostValue());
112-
}
113-
114103
/**
115104
* @return array
116105
* @throws \Exception

app/code/Magento/Contact/Test/Unit/Controller/Index/PostTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function setUp()
7878
$this->createMock(\Magento\Framework\Message\ManagerInterface::class);
7979
$this->requestStub = $this->createPartialMock(
8080
\Magento\Framework\App\Request\Http::class,
81-
['getPostValue', 'getParams', 'getParam']
81+
['getPostValue', 'getParams', 'getParam', 'isPost']
8282
);
8383
$this->redirectResultMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class);
8484
$this->redirectResultMock->method('setPath')->willReturnSelf();
@@ -174,6 +174,10 @@ public function testExecuteValidPost()
174174
*/
175175
private function stubRequestPostData($post)
176176
{
177+
$this->requestStub
178+
->expects($this->once())
179+
->method('isPost')
180+
->willReturn(!empty($post));
177181
$this->requestStub->method('getPostValue')->willReturn($post);
178182
$this->requestStub->method('getParams')->willReturn($post);
179183
$this->requestStub->method('getParam')->willReturnCallback(

app/code/Magento/Customer/etc/di.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,19 @@
340340
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\CollectionProcessor\GroupFilterProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor">
341341
<arguments>
342342
<argument name="fieldMapping" xsi:type="array">
343-
<item name="code" xsi:type="string">customer_group_code</item>
344-
<item name="id" xsi:type="string">customer_group_id</item>
345-
<item name="tax_class_name" xsi:type="string">class_name</item>
343+
<item name="code" xsi:type="string">main_table.customer_group_code</item>
344+
<item name="id" xsi:type="string">main_table.customer_group_id</item>
345+
<item name="tax_class_name" xsi:type="string">tax_class_table.class_name</item>
346346
</argument>
347347
</arguments>
348348
</virtualType>
349349
<!-- @api -->
350350
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\CollectionProcessor\GroupSortingProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor">
351351
<arguments>
352352
<argument name="fieldMapping" xsi:type="array">
353-
<item name="code" xsi:type="string">customer_group_code</item>
354-
<item name="id" xsi:type="string">customer_group_id</item>
355-
<item name="tax_class_name" xsi:type="string">class_name</item>
353+
<item name="code" xsi:type="string">main_table.customer_group_code</item>
354+
<item name="id" xsi:type="string">main_table.customer_group_id</item>
355+
<item name="tax_class_name" xsi:type="string">tax_class_table.class_name</item>
356356
</argument>
357357
<argument name="defaultOrders" xsi:type="array">
358358
<item name="id" xsi:type="string">ASC</item>

app/code/Magento/NewRelicReporting/Model/Config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ public function getNewRelicAppName()
161161
return (string)$this->scopeConfig->getValue('newrelicreporting/general/app_name');
162162
}
163163

164+
/**
165+
* Returns configured separate apps value
166+
*
167+
* @return bool
168+
*/
169+
public function isSeparateApps()
170+
{
171+
return (bool)$this->scopeConfig->getValue('newrelicreporting/general/separate_apps');
172+
}
173+
164174
/**
165175
* Returns config setting for overall cron to be enabled
166176
*

app/code/Magento/NewRelicReporting/Model/NewRelicWrapper.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ public function reportError($exception)
4141
}
4242
}
4343

44+
/**
45+
* Wrapper for 'newrelic_set_appname'
46+
*
47+
* @param string $appName
48+
* @return void
49+
*/
50+
public function setAppName(string $appName)
51+
{
52+
if (extension_loaded('newrelic')) {
53+
newrelic_set_appname($appName);
54+
}
55+
}
56+
4457
/**
4558
* Checks whether newrelic-php5 agent is installed
4659
*
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\NewRelicReporting\Plugin;
7+
8+
use Magento\Framework\App\State;
9+
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\NewRelicReporting\Model\Config;
11+
use Magento\NewRelicReporting\Model\NewRelicWrapper;
12+
use Psr\Log\LoggerInterface;
13+
14+
class StatePlugin
15+
{
16+
/**
17+
* @var Config
18+
*/
19+
private $config;
20+
21+
/**
22+
* @var NewRelicWrapper
23+
*/
24+
private $newRelicWrapper;
25+
26+
/**
27+
* @var LoggerInterface
28+
*/
29+
private $logger;
30+
31+
/**
32+
* @param Config $config
33+
* @param NewRelicWrapper $newRelicWrapper
34+
*/
35+
public function __construct(
36+
Config $config,
37+
NewRelicWrapper $newRelicWrapper,
38+
LoggerInterface $logger
39+
) {
40+
$this->config = $config;
41+
$this->newRelicWrapper = $newRelicWrapper;
42+
$this->logger = $logger;
43+
}
44+
45+
/**
46+
* Set separate appname
47+
*
48+
* @param State $subject
49+
* @param null $result
50+
* @return void
51+
*
52+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
53+
*/
54+
public function afterSetAreaCode(State $state, $result)
55+
{
56+
if (!$this->shouldSetAppName()) {
57+
return $result;
58+
}
59+
60+
try {
61+
$this->newRelicWrapper->setAppName($this->appName($state));
62+
} catch (LocalizedException $e) {
63+
$this->logger->critical($e);
64+
return $result;
65+
}
66+
}
67+
68+
private function appName(State $state)
69+
{
70+
$code = $state->getAreaCode();
71+
$current = $this->config->getNewRelicAppName();
72+
73+
return $current . ';' . $current . '_' . $code;
74+
}
75+
76+
private function shouldSetAppName()
77+
{
78+
if (!$this->config->isNewRelicEnabled()) {
79+
return false;
80+
}
81+
82+
if (!$this->config->getNewRelicAppName()) {
83+
return false;
84+
}
85+
86+
if (!$this->config->isSeparateApps()) {
87+
return false;
88+
}
89+
90+
return true;
91+
}
92+
}

app/code/Magento/NewRelicReporting/etc/adminhtml/system.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
<label>New Relic Application Name</label>
4747
<comment>This is located by navigating to Settings from the New Relic APM website</comment>
4848
</field>
49+
<field id="separate_apps" translate="label comment" type="select" sortOrder="9" showInDefault="1" showInWebsite="1" showInStore="1">
50+
<label>Send Adminhtml and Frontend as Separate Apps</label>
51+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
52+
<comment>In addition to the main app (which includes all PHP execution), separate apps for adminhtml and frontend will be created. Requires New Relic Application Name to be set.</comment>
53+
</field>
4954
</group>
5055
<group id="cron" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
5156
<label>Cron</label>

0 commit comments

Comments
 (0)