ACSD-50858:提高了加载横幅内容的性能

ACSD-50858修补程序修复了购物车/结账页面中的横幅性能问题: 过多的数据库查询以及页面加载时间增加。 安装Quality Patches Tool (QPT) 1.1.31时,此修补程序可用。 修补程序ID为ACSD-50858。 请注意,该问题计划在Adobe Commerce 2.4.7中修复。

受影响的产品和版本

为Adobe Commerce版本创建了修补程序:

  • Adobe Commerce(所有部署方法) 2.4.5-p1

与Adobe Commerce版本兼容:

  • Adobe Commerce(所有部署方法) 2.4.4 - 2.4.6
NOTE
该修补程序可能适用于具有新Quality Patches Tool发行版本的其他版本。 要检查修补程序是否与您的Adobe Commerce版本兼容,请将magento/quality-patches包更新到最新版本,并在Quality Patches Tool:搜索修补程序页面上检查兼容性。 使用修补程序ID作为搜索关键字来查找修补程序。

问题

由于​ 过多的数据库查询和页面加载时间增加,购物车/结帐页面中的横幅性能受到影响。

通过重构横幅内容的加载方式修复了此问题,将数据库查询数量减少了99.99%,页面加载时间减少了约99%。

重现步骤

  1. 登录到管理员并创建一个简单的产品。

  2. 从管理员或前端创建客户,并为其添加送货地址。

  3. 将banners.php移动到magento_root/pub/文件夹。

  4. 使用php pub/banners.php命令生成横幅。 它将生成10,000个简单横幅和1,000个横幅及销售规则。

  5. 登录到之前在前端创建的客户。

  6. 将之前创建的产品添加到购物车。

  7. 转到结帐页面(结帐/购物车)。

  8. 监视banner/ajax/load请求加载时间:

    • 不带bin/magento dev:query-log:enable

    • bin/magento dev:query-log:enable

      code language-none
      grep 'magento_banner_content' var/debug/db.log  | wc -l
      

预期的结果

减少magento_banner_content的数据库查询数和购物车/结帐页面加载时间。

实际结果

增加magento_banner_content的数据库查询数和购物车/结帐页面加载时间。

应用修补程序

要应用单独的修补程序,请根据您的部署方法使用以下链接:

其他信息

banners.php内容

\Banner::class);
    $banner->setIsEnabled(
        \Magento\Banner\Model\Banner::STATUS_ENABLED
    )->setName(
        'Test Dynamic Block '.$i
    )->setTypes(
        ''
    )->setStoreContents(
        [0 => 'Dynamic Block Content '.$i]
    )->save();
}

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

/** @var \Magento\SalesRule\Model\Rule $salesRule */
$salesRule = $objectManager->create(\Magento\SalesRule\Model\Rule::class);
$salesRule->setData(
    [
        'name' => '50% Off ',
        'is_active' => 1,
        'customer_group_ids' => [\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID],
        'coupon_type' => \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON,
        'conditions' => [
            [
                'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class,
                'attribute' => 'base_subtotal',
                'operator' => '>',
                'value' => 0
            ]
        ],
        'simple_action' => 'by_percent',
        'discount_amount' => 50,
        'discount_step' => 0,
        'stop_rules_processing' => 1,
        'website_ids' => [
           1
        ]
    ]
);
$salesRule->save();

for ($i = 0; $i < 1000; $i++) {

    $banner = $objectManager->create(\Magento\Banner\Model\Banner::class);
    $banner->setData(
        [
            'name' => 'Get 50% Off ',
            'is_enabled' => \Magento\Banner\Model\Banner::STATUS_ENABLED,
            'types' => [], /*Any Banner Type*/
            'store_contents' => ['<img src="http://example.com/banner_40_percent_off.png" />'],
            'banner_sales_rules' => [$salesRule->getId()],
        ]
    );
    $banner->save();
}

相关阅读

要了解有关Quality Patches Tool的更多信息,请参阅:

有关QPT中其他可用修补程序的信息,请参阅Quality Patches Tool指南中的Quality Patches Tool:搜索修补程序

recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a