11. Magento 数据库清理
安全模式:清理日常数据库的无用记录
1 | TRUNCATE TABLE `log_visitor`; |
2 | TRUNCATE TABLE `log_visitor_info`; |
3 | TRUNCATE TABLE `log_url`; |
4 | TRUNCATE TABLE `log_url_info`; |
1 | TRUNCATE `log_visitor` ; |
2 | TRUNCATE `log_url_info` ; |
3 | TRUNCATE `log_visitor_info` ; |
4 | TRUNCATE `dataflow_batch_import` ; |
6 | TRUNCATE `report_event` ; |
7 | TRUNCATE `log_visitor_online` ; |
备注:如果是转移网站,URL 重写表 core_url_rewrite 也可清空,转完站重建 URL 即可。
12. 批量修改 SKU、Meta、Name 等字段里的部份词
1 | UPDATE `catalog_product_entity` SET sku= replace (sku, 'oldskuw' , 'newskuw' ) WHERE sku LIKE '%oldskuw%' ; |
2 | UPDATE `catalog_product_entity_text` SET value= replace (value, 'oldmetaw' , 'newmetaw' ) WHERE value LIKE '%oldmetaw%' ; |
3 | UPDATE `catalog_product_entity_varchar` SET value= replace (value, 'oldnamew' , 'newnamew' ) WHERE value LIKE '%oldnamew%' ; |
13. 清站相关提示
能在后台清理的就在后台清理,直接对数据库操作有造成网站出错的可能性。其他辅助命令如下:
清除订单命令:
01 | TRUNCATE `sales_flat_invoice`; |
02 | TRUNCATE `sales_flat_invoice_grid`; |
03 | TRUNCATE `sales_flat_invoice_item`; |
04 | TRUNCATE `sales_flat_order`; |
05 | TRUNCATE `sales_flat_order_address`; |
06 | TRUNCATE `sales_flat_order_grid`; |
07 | TRUNCATE `sales_flat_order_item`; |
08 | TRUNCATE `sales_flat_order_payment`; |
09 | TRUNCATE `sales_flat_order_status_history`; |
10 | TRUNCATE `sales_flat_quote`; |
11 | TRUNCATE `sales_flat_quote_address`; |
12 | TRUNCATE `sales_flat_quote_address_item`; |
13 | TRUNCATE `sales_flat_quote_item`; |
14 | TRUNCATE `sales_flat_quote_item_option`; |
15 | TRUNCATE `sales_flat_quote_payment`; |
16 | TRUNCATE `sales_flat_quote_shipping_rate`; |
1 | TRUNCATE `log_url_info`; |
2 | TRUNCATE `log_visitor_info`; |
4 | TRUNCATE `log_visitor`; |
5 | TRUNCATE `core_url_rewrite`; |
6 | TRUNCATE `report_event`; |
7 | TRUNCATE `report_viewed_product_index`; |
14. 重置 Magento 所有 ID 统计数(如订单编码、发票编码等)
1 | TRUNCATE `eav_entity_store`; |
2 | ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1; |
15. 批量调整指定产品的价格
1 | create table xytmptb SELECT entity_id,value FROM `catalog_product_entity_varchar` WHERE (value LIKE '%Boot%' OR value LIKE '%Shoes%' ) AND attribute_id=60; |
2 | UPDATE `catalog_product_entity_decimal` SET value=value+10 WHERE entity_id IN ( SELECT entity_id FROM `xytmptb`) AND attribute_id=64; |
最后别忘了重建价格索引!
16. 分类与产品的反向开关
1 | UPDATE `catalog_category_entity_int` SET value=if(value=0,1,0) WHERE attribute_id=119; |
2 | UPDATE `catalog_product_entity_int` SET value=if(value=1,2,1) WHERE attribute_id=273; |
运行一下,开的关了,关的开了,再运一下反之,最后别忘了重建索引!
17. 批量禁用产品 —— 数据库操作
1 | CREATE TABLE XYTMPTB SELECT entity_id,value FROM `catalog_product_entity_varchar` WHERE value LIKE 'affliction%' AND attribute_id=96; |
2 | UPDATE `catalog_product_entity_int` SET value=1 WHERE attribute_id=273 AND entity_id IN ( SELECT entity_id FROM `XYTMPTB`); |
别忘了重建索引!
18. 账户之间转移订单
1 | UPDATE `sales_order` SET `customer_id`=newuserid WHERE `customer_id`=olduserid ; |
No comments:
Post a Comment