如何添加虚拟商店和产品进行压力测试?

时间:2020-07-07 00:38:37

标签: mysql magento2

我需要在每个商店中增加2000家商店和5种产品。我打算命名商店store_1,...,store_2000,并在其中各添加5种产品。

搜索了一段时间后,看来这是我可以选择产品的方式:

    SELECT 
    `e`.`sku`, 
    IF(at_name.value_id > 0, at_name.value, at_name_default.value) AS `name`,
    IF(at_description.value_id > 0, at_description.value, at_description_default.value) AS `description`,
    p.price

FROM 
   `myprefix_catalog_product_entity` AS `e` 
    INNER JOIN 
         `myprefix_catalog_product_entity_varchar` AS `at_name_default` 
               ON (`at_name_default`.`entity_id` = `e`.`entity_id`) AND 
                  (`at_name_default`.`attribute_id` = (SELECT attribute_id FROM `myprefix_eav_attribute` ea LEFT JOIN `myprefix_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'name' AND et.entity_type_code = 'catalog_product')) AND 
                  `at_name_default`.`store_id` = 0 
    LEFT JOIN 
          `myprefix_catalog_product_entity_varchar` AS `at_name` 
               ON (`at_name`.`entity_id` = `e`.`entity_id`) AND 
                  (`at_name`.`attribute_id` = (SELECT attribute_id FROM `myprefix_eav_attribute` ea LEFT JOIN `myprefix_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'name' AND et.entity_type_code = 'catalog_product')) AND 
                  (`at_name`.`store_id` = 1) 
    INNER JOIN 
         `myprefix_catalog_product_entity_text` AS `at_description_default` 
               ON (`at_description_default`.`entity_id` = `e`.`entity_id`) AND 
                  (`at_description_default`.`attribute_id` = (SELECT attribute_id FROM `myprefix_eav_attribute` ea LEFT JOIN `myprefix_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'description' AND et.entity_type_code = 'catalog_product')) AND 
                  `at_description_default`.`store_id` = 0 
    LEFT JOIN 
          `myprefix_catalog_product_entity_text` AS `at_description` 
               ON (`at_description`.`entity_id` = `e`.`entity_id`) AND 
                  (`at_description`.`attribute_id` = (SELECT attribute_id FROM `myprefix_eav_attribute` ea LEFT JOIN `myprefix_eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERE `ea`.`attribute_code` = 'description' AND et.entity_type_code = 'catalog_product')) AND 
                  (`at_description`.`store_id` = 1)
join myprefix_catalog_product_index_price p on e.entity_id = p.entity_id;

在我看来myprefix_catalog_product_entitymyprefix_catalog_product_entity_varcharmyprefix_eav_attributemyprefix_catalog_product_index_price共同定义了一个产品。

myprefix_catalog_product_entity_varchar有一个store_id字段,它是对myprefix_store的引用。另一方面,myprefix_store通过website_idgroup_id引用了另外两个表。它们分别是myprefix_store_websitemyprefix_store_group

我会写一些insert命令(明天我会写),但是我担心这样做会错误,因为我对Magento 2如何表示数据没有太多的了解。我想问你的问题如下:

如果我将记录插入上述表中,是否会成功创建商店和产品,或者我还需要做其他事情吗?如何定义所有列的所有值?有一些常识对此有帮助吗?

我看过以下页面:https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-perf-data.html

但是我对Magento缺乏自信才能做到这一点。我希望这里的人比我对此更有经验,并且可以告诉我应该填写哪些表以及我是否还需要其他东西。示例示例也很棒。如果没有解决方案,那么在解决了这个问题之后,我会自己写一个答案。

编辑

编写此代码作为测试:

insert into myprefix_store_website(code, name)
values('stress_test_0001', 'Stress Test 0001');

insert into myprefix_store_group(website_id, name, code, root_category_id)
select website_id, name, code, 2
from myprefix_store_website
where code = 'stress_test_0001';

insert into myprefix_store(code, website_id, group_id, name, is_active)
select code, website_id,  group_id, name, 1
from myprefix_store_group
where code = 'stress_test_0001';

insert into myprefix_catalog_product_index_price(entity_id, customer_group_id, website_id, tax_class_id, price, final_price, min_price, max_price)
select myprefix_catalog_product_index_price.entity_id, myprefix_catalog_product_index_price.customer_group_id, myprefix_store_website.website_id, myprefix_catalog_product_index_price.tax_class_id, myprefix_catalog_product_index_price.price + myprefix_store_website.website_id, myprefix_catalog_product_index_price.price + myprefix_store_website.website_id, myprefix_catalog_product_index_price.price + myprefix_store_website.website_id, myprefix_catalog_product_index_price.price + myprefix_store_website.website_id
from myprefix_catalog_product_index_price
join myprefix_store_website
on myprefix_catalog_product_index_price.entity_id in (112, 111, 109, 108, 104) and myprefix_store_website.code = 'stress_test_0001' and myprefix_catalog_product_index_price.website_id = 1;

insert into myprefix_catalog_product_website(product_id, website_id)
select myprefix_catalog_product_entity.entity_id, myprefix_store_website.website_id
from myprefix_catalog_product_entity
join myprefix_store_website
on myprefix_catalog_product_entity.entity_id in (112, 111, 109, 108, 104) and myprefix_store_website.code = 'stress_test_0001';

但是当我尝试在管理面板中查看产品时,在第5页上会出错。加载新站点也会崩溃。我不知道错误是什么,除了单个日志之外,今天的日志没有显示任何错误,这与我的问题无关。有人有线索吗?

0 个答案:

没有答案