Skip to content

Commit b7edb74

Browse files
committed
Merge remote-tracking branch 'troll-ce/MC-20322' into MC-16108
2 parents f82a156 + 4a4a15b commit b7edb74

File tree

9 files changed

+111
-7
lines changed

9 files changed

+111
-7
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Reports\Setup\Patch\Data;
9+
10+
use Magento\Framework\Notification\NotifierInterface;
11+
12+
/**
13+
* Report Disable Notification
14+
*/
15+
class ReportDisableNotification implements \Magento\Framework\Setup\Patch\DataPatchInterface
16+
{
17+
/**
18+
* @var NotifierInterface
19+
*/
20+
private $notifier;
21+
22+
/**
23+
* @param NotifierInterface $notifier
24+
*/
25+
public function __construct(
26+
NotifierInterface $notifier
27+
) {
28+
$this->notifier = $notifier;
29+
}
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function apply()
35+
{
36+
$message = <<<"MESSAGE"
37+
To improve performance, collecting statistics for the Magento Report module is disabled by default.
38+
You can enable it in System Config.
39+
MESSAGE;
40+
$this->notifier->addNotice(__('Disable Notice'), __($message));
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function getAliases()
47+
{
48+
return [];
49+
}
50+
51+
/**
52+
* @inheritdoc
53+
*/
54+
public static function getDependencies()
55+
{
56+
return [];
57+
}
58+
}

app/code/Magento/Reports/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<mtd_start>1</mtd_start>
2121
</dashboard>
2222
<options>
23-
<enabled>1</enabled>
23+
<enabled>0</enabled>
2424
<product_view_enabled>1</product_view_enabled>
2525
<product_send_enabled>1</product_send_enabled>
2626
<product_compare_enabled>1</product_compare_enabled>

app/code/Magento/Sales/Test/Mftf/Test/MoveRecentlyViewedBundleFixedProductOnOrderPageTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<requiredEntity createDataKey="createBundleOption"/>
5555
<requiredEntity createDataKey="createSecondProduct"/>
5656
</createData>
57+
<!-- Change configuration -->
58+
<magentoCLI command="config:set reports/options/enabled 1" stepKey="enableReportModule"/>
59+
5760
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
5861
</before>
5962
<after>
@@ -73,6 +76,9 @@
7376

7477
<!-- Delete category -->
7578
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
79+
80+
<!-- Change configuration -->
81+
<magentoCLI command="config:set reports/options/enabled 0" stepKey="disableReportModule"/>
7682
</after>
7783

7884
<!-- Login as customer -->

app/code/Magento/Sales/Test/Mftf/Test/MoveRecentlyViewedConfigurableProductOnOrderPageTest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
<requiredEntity createDataKey="createConfigProduct"/>
5858
<requiredEntity createDataKey="createConfigChildProduct"/>
5959
</createData>
60+
<!-- Change configuration -->
61+
<magentoCLI command="config:set reports/options/enabled 1" stepKey="enableReportModule"/>
6062
</before>
6163
<after>
6264
<!-- Admin logout -->
@@ -75,6 +77,9 @@
7577

7678
<!-- Delete category -->
7779
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
80+
81+
<!-- Change configuration -->
82+
<magentoCLI command="config:set reports/options/enabled 0" stepKey="disableReportModule"/>
7883
</after>
7984

8085
<!-- Login as customer -->

dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
use Magento\Catalog\Test\Page\Product\CatalogProductCompare;
1010
use Magento\Catalog\Test\Page\Product\CatalogProductView;
11+
use Magento\Catalog\Test\TestStep\CreateProductsStep;
1112
use Magento\Cms\Test\Page\CmsIndex;
1213
use Magento\Customer\Test\Fixture\Customer;
1314
use Magento\Customer\Test\Page\Adminhtml\CustomerIndex;
1415
use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit;
16+
use Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep;
17+
use Magento\Mtf\Util\Command\Cli\Config;
1518
use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex;
1619
use Magento\Mtf\Client\BrowserInterface;
1720
use Magento\Mtf\TestCase\Injectable;
@@ -91,21 +94,27 @@ class MoveRecentlyComparedProductsOnOrderPageTest extends Injectable
9194
*/
9295
protected $catalogProductCompare;
9396

97+
/**
98+
* @var Config
99+
*/
100+
private $config;
101+
94102
/**
95103
* Create customer.
96-
*
97104
* @param Customer $customer
98105
* @param BrowserInterface $browser
106+
* @param Config $config
99107
* @return array
100108
*/
101-
public function __prepare(Customer $customer, BrowserInterface $browser)
109+
public function __prepare(Customer $customer, BrowserInterface $browser, Config $config)
102110
{
103111
$customer->persist();
104112
// Login under customer
105113
$this->objectManager
106-
->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer])
114+
->create(LoginCustomerOnFrontendStep::class, ['customer' => $customer])
107115
->run();
108116
$this->browser = $browser;
117+
$this->config = $config;
109118

110119
return ['customer' => $customer];
111120
}
@@ -137,20 +146,26 @@ public function __inject(
137146
$this->catalogProductCompare = $catalogProductCompare;
138147
}
139148

149+
public function setUp()
150+
{
151+
$this->config->setConfig('reports/options/enabled', 1);
152+
parent::setUp();
153+
}
154+
140155
/**
141156
* Move recently compared products on order page.
142-
*
143157
* @param Customer $customer
144158
* @param string $products
145159
* @param bool $productsIsConfigured
146160
* @return array
161+
* @throws \Exception
147162
*/
148163
public function test(Customer $customer, $products, $productsIsConfigured = false)
149164
{
150165
// Preconditions
151166
// Create product
152167
$products = $this->objectManager->create(
153-
\Magento\Catalog\Test\TestStep\CreateProductsStep::class,
168+
CreateProductsStep::class,
154169
['products' => $products]
155170
)->run()['products'];
156171
foreach ($products as $itemProduct) {
@@ -171,4 +186,10 @@ public function test(Customer $customer, $products, $productsIsConfigured = fals
171186

172187
return ['products' => $products, 'productsIsConfigured' => $productsIsConfigured];
173188
}
189+
190+
public function tearDown()
191+
{
192+
$this->config->setConfig('reports/options/enabled', 0);
193+
parent::tearDown();
194+
}
174195
}

dev/tests/integration/testsuite/Magento/Backend/Block/Dashboard/Tab/Products/ViewedTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected function setUp()
4949
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
5050
* @magentoDbIsolation enabled
5151
* @magentoAppIsolation enabled
52+
* @magentoConfigFixture default/reports/options/enabled 1
5253
*/
5354
public function testGetPreparedCollectionProductPrice()
5455
{
@@ -57,9 +58,11 @@ public function testGetPreparedCollectionProductPrice()
5758
$product = $this->productRepository->getById(1);
5859
$this->eventManager->dispatch('catalog_controller_product_view', ['product' => $product]);
5960

61+
$collection = $viewedProductsTabBlock->getPreparedCollection();
62+
6063
$this->assertEquals(
6164
10,
62-
$viewedProductsTabBlock->getPreparedCollection()->getFirstItem()->getDataByKey('price')
65+
$collection->getFirstItem()->getDataByKey('price')
6366
);
6467
}
6568
}

dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Dashboard/ProductsViewedTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ProductsViewedTest extends \Magento\TestFramework\TestCase\AbstractBackend
1515
/**
1616
* @magentoAppArea adminhtml
1717
* @magentoDataFixture Magento/Reports/_files/viewed_products.php
18+
* @magentoConfigFixture default/reports/options/enabled 1
1819
*/
1920
public function testExecute()
2021
{

dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Report/Product/Viewed/CollectionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function setUp()
2727

2828
/**
2929
* @magentoDataFixture Magento/Reports/_files/viewed_products.php
30+
* @magentoConfigFixture default/reports/options/enabled 1
3031
*/
3132
public function testGetItems()
3233
{

dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
$simpleDuplicatedId = $productRepository->get('simple-1')->getId();
2121
$virtualId = $productRepository->get('virtual-product')->getId();
2222

23+
$config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
24+
\Magento\Framework\App\Config\MutableScopeConfigInterface::class
25+
);
26+
$config->setValue(
27+
'reports/options/enabled',
28+
1,
29+
\Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT
30+
);
31+
2332
// imitate product views
2433
/** @var \Magento\Reports\Observer\CatalogProductViewObserver $reportObserver */
2534
$reportObserver = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(

0 commit comments

Comments
 (0)