Skip to content

Commit c135fc3

Browse files
authored
Merge pull request #10190 from adobe-commerce-tier-4/PR_2025_11_07_muntianu
[Support Tier-4 muntianu] 11-07-2025 Regular delivery of bugfixes and improvements
2 parents a06a4a5 + 5e84f7b commit c135fc3

File tree

36 files changed

+3799
-148
lines changed

36 files changed

+3799
-148
lines changed

app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SubscriptionUpdateHandler
2424
/**
2525
* Config path for schedule setting of update handler.
2626
*/
27-
public const UPDATE_CRON_STRING_PATH = "crontab/default/jobs/analytics_update/schedule/cron_expr";
27+
public const UPDATE_CRON_STRING_PATH = "crontab/analytics/jobs/analytics_update/schedule/cron_expr";
2828

2929
/**
3030
* Flag code for the previous Base URL.

app/code/Magento/Analytics/Model/Config/Backend/CollectionTime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CollectionTime extends Value
2323
/**
2424
* The path to config setting of schedule of collection data cron.
2525
*/
26-
public const CRON_SCHEDULE_PATH = 'crontab/default/jobs/analytics_collect_data/schedule/cron_expr';
26+
public const CRON_SCHEDULE_PATH = 'crontab/analytics/jobs/analytics_collect_data/schedule/cron_expr';
2727

2828
/**
2929
* @var WriterInterface

app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SubscriptionHandler
2424
/**
2525
* Config path for schedule setting of subscription handler.
2626
*/
27-
public const CRON_STRING_PATH = 'crontab/default/jobs/analytics_subscribe/schedule/cron_expr';
27+
public const CRON_STRING_PATH = 'crontab/analytics/jobs/analytics_subscribe/schedule/cron_expr';
2828

2929
/**
3030
* Config value for schedule setting of subscription handler.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Analytics\Setup\Patch\Data;
10+
11+
use Magento\Framework\App\ResourceConnection;
12+
use Magento\Framework\Setup\Patch\DataPatchInterface;
13+
14+
/**
15+
* Migrate legacy cron config paths for analytics jobs from the "default" group to the "analytics" group.
16+
*/
17+
class MoveCronConfigToAnalyticsGroup implements DataPatchInterface
18+
{
19+
/**
20+
* @var ResourceConnection
21+
*/
22+
private $resourceConnection;
23+
24+
/**
25+
* @param ResourceConnection $resourceConnection
26+
*/
27+
public function __construct(
28+
ResourceConnection $resourceConnection
29+
) {
30+
$this->resourceConnection = $resourceConnection;
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function apply()
37+
{
38+
$connection = $this->resourceConnection->getConnection();
39+
$table = $this->resourceConnection->getTableName('core_config_data');
40+
41+
// Find all analytics cron rows under the "default" cron group
42+
$select = $connection->select()
43+
->from($table, ['config_id', 'scope', 'scope_id', 'path', 'value'])
44+
->where('path LIKE ?', 'crontab/default/jobs/analytics_%');
45+
$rows = (array)$connection->fetchAll($select);
46+
47+
foreach ($rows as $row) {
48+
$oldPath = (string)$row['path'];
49+
$newPath = (string)preg_replace('#^crontab/default/#', 'crontab/analytics/', $oldPath);
50+
51+
$connection->update(
52+
$table,
53+
['path' => $newPath],
54+
['config_id = ?' => (int)$row['config_id']]
55+
);
56+
}
57+
58+
return $this;
59+
}
60+
61+
/**
62+
* @inheritDoc
63+
*/
64+
public static function getDependencies()
65+
{
66+
return [];
67+
}
68+
69+
/**
70+
* @inheritDoc
71+
*/
72+
public function getAliases()
73+
{
74+
return [];
75+
}
76+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
9+
<group id="analytics">
10+
<schedule_generate_every>15</schedule_generate_every>
11+
<schedule_ahead_for>20</schedule_ahead_for>
12+
<schedule_lifetime>15</schedule_lifetime>
13+
<history_cleanup_every>10</history_cleanup_every>
14+
<history_success_lifetime>60</history_success_lifetime>
15+
<history_failure_lifetime>4320</history_failure_lifetime>
16+
<use_separate_process>1</use_separate_process>
17+
</group>
18+
</config>

app/code/Magento/Analytics/etc/crontab.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:module:Magento_Cron:etc/crontab.xsd">
9-
<group id="default">
9+
<group id="analytics">
1010
<job name="analytics_subscribe" instance="Magento\Analytics\Cron\SignUp" method="execute" />
1111
<job name="analytics_update" instance="Magento\Analytics\Cron\Update" method="execute" />
1212
<job name="analytics_collect_data" instance="Magento\Analytics\Cron\CollectData" method="execute" />

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@
260260
<item name="analytics/general/token" xsi:type="string">1</item>
261261
</argument>
262262
<argument name="environment" xsi:type="array">
263-
<item name="crontab/default/jobs/analytics_collect_data/schedule/cron_expr" xsi:type="string">1</item>
264-
<item name="crontab/default/jobs/analytics_update/schedule/cron_expr" xsi:type="string">1</item>
265-
<item name="crontab/default/jobs/analytics_subscribe/schedule/cron_expr" xsi:type="string">1</item>
263+
<item name="crontab/analytics/jobs/analytics_collect_data/schedule/cron_expr" xsi:type="string">1</item>
264+
<item name="crontab/analytics/jobs/analytics_update/schedule/cron_expr" xsi:type="string">1</item>
265+
<item name="crontab/analytics/jobs/analytics_subscribe/schedule/cron_expr" xsi:type="string">1</item>
266266
</argument>
267267
</arguments>
268268
</type>

app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,23 @@ public function updateCustomerFromVisitor($object)
259259
return $this;
260260
}
261261

262+
/**
263+
* Assign customer to compare list items
264+
*
265+
* @param int $listId
266+
* @param int $customerId
267+
* @return $this
268+
*/
269+
public function updateCustomerIdForListItems(int $listId, int $customerId)
270+
{
271+
$this->getConnection()->update(
272+
$this->getMainTable(),
273+
['customer_id' => $customerId],
274+
['list_id = ?' => $listId]
275+
);
276+
return $this;
277+
}
278+
262279
/**
263280
* Clear compare items by visitor and/or customer
264281
*
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Model\Indexer;
9+
10+
use Magento\Framework\DB\Adapter\AdapterInterface;
11+
use Magento\Framework\Indexer\BatchSizeManagementInterface;
12+
13+
/**
14+
* Calculate and validate batch size for catalogrule insert operations
15+
*/
16+
class CatalogRuleInsertBatchSizeCalculator
17+
{
18+
/**
19+
* Default batch size for insert operations
20+
*/
21+
private const DEFAULT_BATCH_SIZE = 5000;
22+
23+
/**
24+
* @var BatchSizeManagementInterface
25+
*/
26+
private $batchSizeManagement;
27+
28+
/**
29+
* @var int
30+
*/
31+
private $defaultBatchSize;
32+
33+
/**
34+
* @param BatchSizeManagementInterface $batchSizeManagement
35+
* @param int $defaultBatchSize
36+
*/
37+
public function __construct(
38+
BatchSizeManagementInterface $batchSizeManagement,
39+
int $defaultBatchSize = self::DEFAULT_BATCH_SIZE
40+
) {
41+
$this->batchSizeManagement = $batchSizeManagement;
42+
$this->defaultBatchSize = $defaultBatchSize;
43+
}
44+
45+
/**
46+
* Retrieve validated batch size for insert operations
47+
*
48+
* @param AdapterInterface $connection
49+
* @return int
50+
*/
51+
public function getInsertBatchSize(AdapterInterface $connection): int
52+
{
53+
$batchSize = $this->defaultBatchSize;
54+
55+
$this->batchSizeManagement->ensureBatchSize($connection, $batchSize);
56+
57+
return (int)$batchSize;
58+
}
59+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRule\Model\Indexer;
9+
10+
use Magento\Framework\App\ResourceConnection;
11+
use Magento\Framework\Indexer\IndexTableRowSizeEstimatorInterface;
12+
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
15+
/**
16+
* Estimator of the catalogrule_product_price index table row size.
17+
*
18+
* @see \Magento\Framework\Indexer\BatchSizeManagement
19+
*/
20+
class CatalogRuleProductPriceRowSizeEstimator implements IndexTableRowSizeEstimatorInterface
21+
{
22+
/**
23+
* Approximate size of catalogrule_product_price row in bytes
24+
* Based on table structure:
25+
* - rule_product_price_id: 4 bytes (int)
26+
* - rule_date: 3 bytes (date)
27+
* - customer_group_id: 4 bytes (int)
28+
* - product_id: 4 bytes (int)
29+
* - rule_price: 8 bytes (decimal)
30+
* - website_id: 2 bytes (smallint)
31+
* - latest_start_date: 3 bytes (date)
32+
* - earliest_end_date: 3 bytes (date)
33+
* Plus index overhead (~30%)
34+
*/
35+
private const APPROXIMATE_ROW_SIZE_BYTES = 150;
36+
37+
/**
38+
* @var ResourceConnection
39+
*/
40+
private $resourceConnection;
41+
42+
/**
43+
* @var CustomerGroupCollectionFactory
44+
*/
45+
private $customerGroupCollectionFactory;
46+
47+
/**
48+
* @var StoreManagerInterface
49+
*/
50+
private $storeManager;
51+
52+
/**
53+
* @param ResourceConnection $resourceConnection
54+
* @param CustomerGroupCollectionFactory $customerGroupCollectionFactory
55+
* @param StoreManagerInterface $storeManager
56+
*/
57+
public function __construct(
58+
ResourceConnection $resourceConnection,
59+
CustomerGroupCollectionFactory $customerGroupCollectionFactory,
60+
StoreManagerInterface $storeManager
61+
) {
62+
$this->resourceConnection = $resourceConnection;
63+
$this->customerGroupCollectionFactory = $customerGroupCollectionFactory;
64+
$this->storeManager = $storeManager;
65+
}
66+
67+
/**
68+
* @inheritdoc
69+
*/
70+
public function estimateRowSize()
71+
{
72+
$customerGroupCount = $this->customerGroupCollectionFactory->create()->getSize();
73+
74+
$websiteCount = count($this->storeManager->getWebsites());
75+
76+
$estimatedRowsPerProduct = $customerGroupCount * $websiteCount * 2;
77+
78+
$memoryPerProduct = $estimatedRowsPerProduct * self::APPROXIMATE_ROW_SIZE_BYTES;
79+
80+
return (int)ceil($memoryPerProduct);
81+
}
82+
}

0 commit comments

Comments
 (0)