Skip to content

Commit c20cfa4

Browse files
committed
Merge branch 'MC-31767' into ar-pr
2 parents e7cda63 + 85d0400 commit c20cfa4

File tree

19 files changed

+615
-45
lines changed

19 files changed

+615
-45
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Analytics\Setup\Patch\Data;
10+
11+
use Magento\Analytics\Model\Config\Backend\CollectionTime;
12+
use Magento\Analytics\Model\SubscriptionStatusProvider;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\Framework\Setup\Patch\DataPatchInterface;
16+
17+
/**
18+
* Activate data collection mechanism
19+
*/
20+
class ActivateDataCollection implements DataPatchInterface
21+
{
22+
/**
23+
* @var ScopeConfigInterface
24+
*/
25+
private $scopeConfig;
26+
27+
/**
28+
* @var SubscriptionStatusProvider
29+
*/
30+
private $subscriptionStatusProvider;
31+
32+
/**
33+
* @var string
34+
*/
35+
private $analyticsCollectionTimeConfigPath = 'analytics/general/collection_time';
36+
37+
/**
38+
* @var CollectionTime
39+
*/
40+
private $collectionTimeBackendModel;
41+
42+
/**
43+
* @param ScopeConfigInterface $scopeConfig
44+
* @param SubscriptionStatusProvider $subscriptionStatusProvider
45+
* @param CollectionTime $collectionTimeBackendModel
46+
*/
47+
public function __construct(
48+
ScopeConfigInterface $scopeConfig,
49+
SubscriptionStatusProvider $subscriptionStatusProvider,
50+
CollectionTime $collectionTimeBackendModel
51+
) {
52+
$this->scopeConfig = $scopeConfig;
53+
$this->subscriptionStatusProvider = $subscriptionStatusProvider;
54+
$this->collectionTimeBackendModel = $collectionTimeBackendModel;
55+
}
56+
57+
/**
58+
* @inheritDoc
59+
*
60+
* @throws LocalizedException
61+
*/
62+
public function apply()
63+
{
64+
$subscriptionStatus = $this->subscriptionStatusProvider->getStatus();
65+
$isCollectionProcessActivated = $this->scopeConfig->getValue(CollectionTime::CRON_SCHEDULE_PATH);
66+
if ($subscriptionStatus !== $this->subscriptionStatusProvider->getStatusForDisabledSubscription()
67+
&& !$isCollectionProcessActivated
68+
) {
69+
$this->collectionTimeBackendModel
70+
->setValue($this->scopeConfig->getValue($this->analyticsCollectionTimeConfigPath));
71+
$this->collectionTimeBackendModel->setPath($this->analyticsCollectionTimeConfigPath);
72+
$this->collectionTimeBackendModel->afterSave();
73+
}
74+
75+
return $this;
76+
}
77+
78+
/**
79+
* @inheritDoc
80+
*/
81+
public function getAliases()
82+
{
83+
return [];
84+
}
85+
86+
/**
87+
* @inheritDoc
88+
*/
89+
public static function getDependencies()
90+
{
91+
return [
92+
PrepareInitialConfig::class,
93+
];
94+
}
95+
}

app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\Analytics\Setup\Patch\Data;
810

911
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
12+
use Magento\Config\Model\Config\Source\Enabledisable;
1013
use Magento\Framework\Setup\ModuleDataSetupInterface;
1114
use Magento\Framework\Setup\Patch\DataPatchInterface;
1215
use Magento\Framework\Setup\Patch\PatchVersionInterface;
1316

1417
/**
15-
* Initial patch.
16-
*
17-
* @package Magento\Analytics\Setup\Patch
18+
* Active subscription process for Advanced Reporting
1819
*/
1920
class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
2021
{
@@ -24,66 +25,63 @@ class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
2425
private $moduleDataSetup;
2526

2627
/**
27-
* PrepareInitialConfig constructor.
28+
* @var SubscriptionHandler
29+
*/
30+
private $subscriptionHandler;
31+
32+
/**
33+
* @var string
34+
*/
35+
private $subscriptionEnabledConfigPath = 'analytics/subscription/enabled';
36+
37+
/**
2838
* @param ModuleDataSetupInterface $moduleDataSetup
39+
* @param SubscriptionHandler $subscriptionHandler
2940
*/
3041
public function __construct(
31-
ModuleDataSetupInterface $moduleDataSetup
42+
ModuleDataSetupInterface $moduleDataSetup,
43+
SubscriptionHandler $subscriptionHandler
3244
) {
3345
$this->moduleDataSetup = $moduleDataSetup;
46+
$this->subscriptionHandler = $subscriptionHandler;
3447
}
3548

3649
/**
37-
* {@inheritdoc}
50+
* @inheritDoc
3851
*/
3952
public function apply()
4053
{
41-
$this->moduleDataSetup->getConnection()->insertMultiple(
54+
$this->moduleDataSetup->getConnection()->insert(
4255
$this->moduleDataSetup->getTable('core_config_data'),
4356
[
44-
[
45-
'scope' => 'default',
46-
'scope_id' => 0,
47-
'path' => 'analytics/subscription/enabled',
48-
'value' => 1
49-
],
50-
[
51-
'scope' => 'default',
52-
'scope_id' => 0,
53-
'path' => SubscriptionHandler::CRON_STRING_PATH,
54-
'value' => join(' ', SubscriptionHandler::CRON_EXPR_ARRAY)
55-
]
57+
'path' => $this->subscriptionEnabledConfigPath,
58+
'value' => Enabledisable::ENABLE_VALUE,
5659
]
5760
);
5861

59-
$this->moduleDataSetup->getConnection()->insert(
60-
$this->moduleDataSetup->getTable('flag'),
61-
[
62-
'flag_code' => SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE,
63-
'state' => 0,
64-
'flag_data' => 24,
65-
]
66-
);
62+
$this->subscriptionHandler->processEnabled();
63+
64+
return $this;
6765
}
6866

6967
/**
70-
* {@inheritdoc}
68+
* @inheritDoc
7169
*/
7270
public static function getDependencies()
7371
{
7472
return [];
7573
}
7674

7775
/**
78-
* {@inheritdoc}
76+
* @inheritDoc
7977
*/
8078
public static function getVersion()
8179
{
8280
return '2.0.0';
8381
}
8482

8583
/**
86-
* {@inheritdoc}
84+
* @inheritDoc
8785
*/
8886
public function getAliases()
8987
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
<label>Time of day to send data</label>
2929
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel</frontend_model>
3030
<backend_model>Magento\Analytics\Model\Config\Backend\CollectionTime</backend_model>
31+
<depends>
32+
<field id="analytics/general/enabled">1</field>
33+
</depends>
3134
</field>
3235
<field id="vertical" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
3336
<hint>Industry Data</hint>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9-
<preference for="Magento\Analytics\ReportXML\ConfigInterface" type="Magento\Analytics\ReportXML\Config" />
9+
<preference for="Magento\Analytics\ReportXml\ConfigInterface" type="Magento\Analytics\ReportXml\Config" />
1010
<preference for="Magento\Analytics\Model\ConfigInterface" type="Magento\Analytics\Model\Config" />
1111
<preference for="Magento\Analytics\Model\ReportWriterInterface" type="Magento\Analytics\Model\ReportWriter" />
1212
<preference for="Magento\Analytics\Api\LinkProviderInterface" type="Magento\Analytics\Model\LinkProvider" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertSeeProductDetailsOnStorefrontRecentlyViewedWidgetActionGroup">
12+
<annotations>
13+
<description>Goes to the home Page Recently VIewed Product and Grab the Prdouct name and Position from it.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="productName" type="string"/>
17+
<argument name="productPosition" type="string"/>
18+
</arguments>
19+
<grabTextFrom selector="{{StoreFrontRecentlyViewedProductSection.ProductName(productPosition)}}" stepKey="grabRelatedProductPosition"/>
20+
<assertContains expected="{{productName}}" actual="$grabRelatedProductPosition" stepKey="assertRelatedProductName"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="RecentlyViewedProductScopeStore">
12+
<data key="path">catalog/recently_products/scope</data>
13+
<data key="value">store</data>
14+
</entity>
15+
<entity name="RecentlyViewedProductScopeWebsite">
16+
<data key="path">catalog/recently_products/scope</data>
17+
<data key="value">website</data>
18+
</entity>
19+
<entity name="RecentlyViewedProductScopeStoreGroup">
20+
<data key="path">catalog/recently_products/scope</data>
21+
<data key="value">group</data>
22+
</entity>
23+
</entities>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
12+
<section name="StoreFrontRecentlyViewedProductSection">
13+
<element name="ProductName" type="text" selector="//div[@class='products-grid']/ol/li[position()={{position}}]/div/div[@class='product-item-details']/strong/a" parameterized="true"/>
14+
</section>
15+
</sections>

0 commit comments

Comments
 (0)