于洋博客 互联网点滴记忆

25Jul/110

如何快速清除Magento中的产品和分类

产品上货资料是采集回来的,有的时候发现更好的源头重新采集需要重新上货。但是很多cms_page和static_block希望保留,因此可以执行如下代码专门清除产品和分类数据:
分类相关:
TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;
INSERT INTO `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`POSITION`,`level`,`children_count`) VALUES (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);
INSERT INTO `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,32,0,2,1),(2,3,32,1,2,1);
INSERT INTO `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');

产品相关:
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;
TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
insert into `catalog_product_link_type`(`link_type_id`,`code`) values (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
insert into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
insert into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,'Default');

Filed under: Magento No Comments
22Jul/110

Bash快捷键

Ctrl-A 相当于HOME键,用于将光标定位到本行最前面

Ctrl-E 相当于End键,即将光标移动到本行末尾

Ctrl-B 相当于左箭头键,用于将光标向左移动一格

Ctrl-F 相当于右箭头键,用于将光标向右移动一格

Ctrl-D 相当于Del键,即删除光标所在处的字符

Ctrl-K 用于删除从光标处开始到结尾处的所有字符

Ctrl-L 清屏,相当于clear命令

Ctrl-R 进入历史命令查找状态,然后你输入几个关键字符,就可以找到你使用过的命令

Ctrl-U 用于删除从光标开始到行首的所有字符。一般在密码或命令输入错误时常用

Ctrl-H 删除光标左侧的一个字符

Ctrl-W 用于删除当前光标左侧的一个单词

Ctrl-P 相当于上箭头键,即显示上一个命令

Ctrl-N 相当于下箭头键,即显示下一个命令

Ctrl-T 用于颠倒光标所在处字符和前一个字符的位置。

Ctrl-J 相当于回车键

Alt-. 用于提取历史命令中的最后一个单词。你先执行history命令,然后再敲击此快捷键若干下,你就懂了!

Alt-BackSpace 用于删除本行所有的内容,基本上和Ctrl-U类似。

Alt-C 用于将当前光标处的字符变成大写,同时本光标所在单词的后续字符都变成小写。

Alt-L 用于将光标所在单词及所在单词的后续字符都变成小写。

Alt-U 用于将光标所在单词的光标所在处及之后的所有字符变成大写。

Filed under: Linux No Comments
5Jul/110

SSH反向连接管理内网Linux

/root/script/pssh
killall ssh
ssh -f -N -R 8822:localhost:22 root@xxx.xxx.xxx.xxx -p xxxx
ssh -f -N -R 7722:localhost:22 root@yyy.yyy.yyy.yyy

On xxx.xxx.xxx.xxx
ssh root@localhost -p 8822

On yyy.yyy.yyy.yyy
ssh root@localhost -p 7722

要在远程主机上建立本地主机的信任关系:
参考http://www.yuyangblog.com/2010/09/ssh下rsync备份不输密码/

Filed under: Lamp No Comments
2Jul/110

sql to reproduce a set of magento cms_page and cms_block

update core_store set name='United States' where code='en';
update core_store set name='United Kingdom' where code='uk';

insert into core_store values (4,'uk',1,1,'United Kingdom',0,1);

insert into cms_page (title,root_template,meta_keywords,meta_description ,identifier ,content_heading,content,creation_time,update_time,is_active,sort_order ,layout_update_xml,custom_theme ,custom_root_template ,custom_layout_update_xml ,custom_theme_from,custom_theme_to) (select title,root_template,meta_keywords,meta_description ,identifier ,content_heading,content,creation_time,update_time,is_active,sort_order ,layout_update_xml,custom_theme ,custom_root_template ,custom_layout_update_xml ,custom_theme_from,custom_theme_to from cms_page where page_id in (select page_id from cms_page_store where store_id=1));

insert into cms_page_store (page_id,store_id) (select page_id,'4' from cms_page where page_id not in (select page_id from cms_page_store));

insert into cms_block (title,identifier,content,creation_time,update_time,is_active) (select title,identifier,content,creation_time,update_time,is_active from cms_block where block_id in (select block_id from cms_block_store where store_id=1));

insert into cms_block_store (block_id,store_id) (select block_id,'4' from cms_block where block_id not in (select block_id from cms_block_store));

Filed under: Magento No Comments