国际电子商务技术 & Magento开发公司

Maishen technologies

Welcome visitor! You canlogin orcreate an account.

热线:+86-0532-58973093

麦神科技有限公司
Mygod Technologies

官方认证开发工程师

magento批量删除产品

2011年10月15日星期六 Asia/Shanghai上午9:15:23

对于magento,产品的数据是分散到好多表里,所以增删改查是非常慢的,当然,magneto不乏是一个优秀的系统,当你index manager的时候,你会发现你的数据库中多出了一个带有flat的表,譬如表:catalog_category_flat_store_1catalog_product_flat_1等,都是magento在index magager的时候生成的表,目的是将这些分散的表的信息合并成一个表的信息!

言归正传!

后台删除magento的产品数据是很费劲的事情,我们要做的就是批量删除magento产品,通过mysql到直接使用sql语句批量删除magento产品数据是最好不过的事情,下面是sql语句,使用phpmyadmin,粘贴上直接执行就可以,我测试过,没有问题,如果你感觉不妥,可以先备份数据库,以免出现麻烦!

let ‘s  go-------------------->

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');

0 Comments | Posted in magento日常所用 By terry water

使用火狐插件FireLogger进行magento的调试

2011年10月14日星期五 Asia/Shanghai下午5:57:03

magento的调试,可以通过类似php的加入exit的断点调试,

还可以使用log进行调试

log的调试,比较费劲,还要去查看日志文件

现在介绍一种新的调试方法

首先:

1

下载火狐浏览器

2

安装火狐浏览器插件

网址:

http://firelogger.binaryage.com/ https://addons.mozilla.org/en-us/firefox/addon/firelogger/

3

安装完毕后

下载一个magento的插件:

magento firelogger插件

然后覆盖到你的网站上

4

重启火狐,看是否有一个logger的图标

 

5

随便找个执行的phtml文件里面写上代码

譬如page/html/header.phtml

 

Mage::helper('firelogger')->log('Hello world!');
$product = Mage::getModel('catalog/product')->load(100);
Mage::helper('firelogger')->debug($product);

 

当然,load是你的产品的ID,如果你的产品里面没有ID为100的产品,那么你写的有的ID

6

执行完

查看firelogger

你会发现如图所示的信息,由于产品信息太多,你需要点击更多,在右边查看!

转载请标注地址!

0 Comments | Posted in magento日常所用 By terry

magento-调出高搜索量关键字--topsearch

2011年10月12日星期三 Asia/Shanghai下午1:16:13

对于magento电子商务网店来说,高搜索词代表着高的实用性,客户喜欢度,所以,我们要通过程序把高搜索词调出来,因为这个是很重要的,这里的产品是客户需要的,可以通过下面的代码调用出来magento的高搜索词,magento top search!

 

$_collection = Mage::getModel('catalogsearch/query')->getResourceCollection()  
    ->setPopularQueryFilter($storeid)  
        ->setPageSize($count)  
    ->load(true);  
   
foreach ($this->$_collection->getItems() as $item):  
        echo $item->getQueryText()  
endforeach;  
   
Mage::getUrl('catalogsearch/result')."?q=". $_item->getName() 

一般放在搜索按钮的下面或者旁边,让客户一目了然!donot make me to think----->

0 Comments | Posted in magento日常所用 By terry water

magento订单删除---数据库sql方式

2011年10月12日星期三 Asia/Shanghai下午1:11:26


关于magento的订单删除,好像涉及到法律的问题,所以magento,没有这个功能,虽然本身没有这个功能,也是有插件的,可以实现,但是magento的1.4.2不好用,所以,用sql删除也是不错的选择

 

通过下面的sql语句进行删除,删除前先备份:

1.4版本:

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `catalogsearch_query`;
ALTER TABLE `catalogsearch_query` AUTO_INCREMENT=1;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

 

 

 

老版本,大致,1,3!!

Delete test orders in Magento

SET FOREIGN_KEY_CHECKS=0;
 
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE`sales_order_entity_varchar`;
TRUNCATE`sales_order_int`;
TRUNCATE`sales_order_text`;
TRUNCATE`sales_order_varchar`;
TRUNCATE`sales_flat_quote`;
TRUNCATE`sales_flat_quote_address`;
TRUNCATE`sales_flat_quote_address_item`;
TRUNCATE`sales_flat_quote_item`;
TRUNCATE`sales_flat_quote_item_option`;
TRUNCATE`sales_flat_order_item`;
TRUNCATE`sendfriend_log`;
TRUNCATE`tag`;
TRUNCATE`tag_relation`;
TRUNCATE`tag_summary`;
TRUNCATE`wishlist`;
TRUNCATE`log_quote`;
TRUNCATE`report_event`;
 
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
 
-- reset customers
TRUNCATE`customer_address_entity`;
TRUNCATE`customer_address_entity_datetime`;
TRUNCATE`customer_address_entity_decimal`;
TRUNCATE`customer_address_entity_int`;
TRUNCATE`customer_address_entity_text`;
TRUNCATE`customer_address_entity_varchar`;
TRUNCATE`customer_entity`;
TRUNCATE`customer_entity_datetime`;
TRUNCATE`customer_entity_decimal`;
TRUNCATE`customer_entity_int`;
TRUNCATE`customer_entity_text`;
TRUNCATE`customer_entity_varchar`;
TRUNCATE`log_customer`;
TRUNCATE`log_visitor`;
TRUNCATE`log_visitor_info`;
 
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
 
-- Reset all ID counters
TRUNCATE`eav_entity_store`;
ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;
 
SET FOREIGN_KEY_CHECKS=1;

缺点就是删除的是全部,而不是一部分,所以实用范围为,模板制作测试遗留的订单删除,而不适应于上线的网站!

0 Comments | Posted in magento日常所用 By terry water

magento的.htaccess文件

2011年10月12日星期三 Asia/Shanghai下午1:04:14

magento的.htaccess文件

在使用.htaccess文件的时候:

1

sample.com   301重定向到:www.sample.com

 

 RewriteEngine on

RewriteCond %{HTTP_HOST} ^sample.com [NC]
RewriteRule ^(.*)$ http://www.sample.com/$1 [L,R=301]

2

屏蔽某个IP的访问:

 deny from 71.84.196.66

3

在移动问价打包的时候,就会出现.htaccess文件丢失的现象,这样需要重新加上,否则,做的设置就没了

4

下面是一个access实例:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi

#    Action php5-cgi /cgi-bin/php5-cgi
#    AddHandler php5-cgi .php

############################################
## GoDaddy specific options

#   Options -MultiViews

## you might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

############################################
## this line is specific for 1and1 hosting

    #AddType x-mapp-php5 .php
    #AddHandler x-mapp-php5 .php

############################################
## default index file

    DirectoryIndex index.php

<IfModule mod_php5.c>

############################################
## adjust memory limit

#    php_value memory_limit 64M
    php_value memory_limit 128M
    php_value max_execution_time 18000

############################################
## disable magic quotes for php request vars

    php_flag magic_quotes_gpc off

############################################
## disable automatic session start
## before autoload was initialized

    php_flag session.auto_start off

############################################
## enable resulting html compression

    php_flag zlib.output_compression on

###########################################
# disable user agent verification to not break multiple image upload

    php_flag suhosin.session.cryptua off

###########################################
# turn off compatibility with PHP4 when dealing with objects

    php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload

    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

    # Insert filter on all content
    SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary

</IfModule>

<IfModule mod_ssl.c>

############################################
## make HTTPS env vars available for CGI mode

    SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

RewriteCond %{HTTP_HOST} ^sample.com [NC]
RewriteRule ^(.*)$ http://www.sample.com/$1 [L,R=301]


############################################
## you can put here your magento root folder
## path relative to web root

    #RewriteBase /magento/

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>


############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

    AddDefaultCharset Off
    #AddDefaultCharset UTF-8

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresDefault "access plus 1 year"

</IfModule>

############################################
## By default allow all access

    Order allow,deny
    Allow from all
    deny from 71.84.196.66
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags

    #FileETag none
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

再就是一些别的设置了,

譬如开始gzip等,一些模块等,需要在这里设置一下

有一些文件,譬如存放数据库信息的文件是不允许别人访问的,所以,我要屏蔽所有人访问,可以使用下面的格式设置magento 的.htaccess文件:

Order deny,allow
Deny from all

 

在app,var,等包下,你可以看到一个htaccess文件,里面的内容和上面一样,是不可以删除的,如果删除掉,别人通过

www.sample.com/app/etc/local.xml访问这个地址,直接就可以查看到你的数据库信息,这是很危险的!

0 Comments | Posted in magento日常所用 By magento use
 
  • Mygod Technologies
  • 麦神科技有限公司
  • 香港中路8号
  • 中铁青岛中心大厦A3001
  • 市南区, 青岛, 266000
  • 电话: 0532-5897-3093

订阅我们的最新消息。

我们将严格尊重您的隐私。

关注我们的微信
获取外贸电子商务最新资讯;跨境推广最新策略;电子商务网站技术最新趋势。

2018 Mygod Technologies. 保留所有权. Privacy Policy