Magento积累的知识
1,magento解决安装主题错误后出现503错误
在magento 安装目录将:maintenance.flag 重名为maintenance.flag_bak
2,去掉首页paypal图标:
配置->支付方式->paypal快速结帐->前端体验设置(paypay产品徽标->没有标示)
3.去掉首页投票工具:
CMS->投票->关闭投票
4.取消模块:
系统->高级->高级->Mage_Newsletter 选折“禁用”
5.取消左边Left Callout banner (the dog)与右边Right Callout banner (back to school)
(参考:http://www.magentocommerce.com/knowledge-base/entry/turning-on-off-magentos-content-blocks)
/var/www/magento.com/app/design/frontend/base/default/layout
6,在主菜单中添加“首页”:
将“<a class=”level-top” href=”<?php echo $this->getUrl(”)?>”>”
/var/www/magento.com/app/design/frontend/base/default/template/page/html$ sudo geany topmenu.phtml
7,在首页显示类别产品:
{{block type=”catalog/product_list” column_count=”4″ category_id=”3″ template=”catalog/product/list.phtml”}}
或者:
{{block type=”catalog/product_list” name=”home.catalog.product.list” category_id=”6″ alias=”products_homepage” template=”catalog/product/list.phtml”}}
8,在产品详细界面显示左菜单:
调整产品的布局,将产品的布局调整为3栏或左中俩栏
9,修改每行显示产品数量:
截取代码片段如下:
/var/www/magento.com/app/design/frontend/base/default/template/catalog/product$ sudo geany list.phtml
<?php $_columnCount = $this->getColumnCount(); ?> //搜下“columnCount”关键字就搜到
将其改为
<?php $_columnCount = 4 ?>
这样就每行显示4个产品了,想显示5个就改成5。
10,magento导入j或css
<script src=”<?php echo $this->getJsUrl(); ?>Common_1205141001.js” type=”text/javascript”></script>
<link rel=”stylesheet” type=”text/css” href=”<?php echo $this->getSkinUrl(‘css/magebuzz/productslider/slider.css’)?>”/>
11,magento 中”product slide”插件在页面位置的调整:
/app/design/frontend/default/default/layout/productslider.xml
magento中block 是通过 before与after来调整位置的,
old:<block type=”productslider/position” before=”-” name=”home.productslider”/>
new:<block type=”productslider/position” after=”category.products” name=”home.productslider”/>
12,在产品显示页面添加百度分享按钮:
/var/www/magento.com/app/design/frontend/default/default/template/relproslider/product$ sudo geany view.phtml
13,在产品显示页面添加显示重量:
/var/www/magento.com/app/design/frontend/default/default/template/relproslider/product$ sudo geany view.phtml
<div id=”weight”><span>净含量:</span>
<?php
$_weight = $this->htmlEscape($_product->getWeight());
if ($_weight < 1)
$_weightstr = number_format($_weight*1000,2) . ” gr”;
else
$_weightstr = number_format($_weight,2) . “g”;
echo $_weightstr;
?>
</div>
14,修改产品价格显示方式:
/var/www/magento.com/app/design/frontend/base/default/template/productalert$ sudo geany price.phtml (1.7)
/var/www/magento.com/app/design/frontend/base/default/template/catalog/product$ sudo geany price.phtml (1.8)
<span class=”regular-price” id=”product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>”>
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?> /
<?php
$_weight = $this->htmlEscape($_product->getWeight());
if ($_weight < 1)
$_weightstr = number_format($_weight*1000,2) . “g”;
else
$_weightstr = number_format($_weight,2) . “Kg”;
echo $_weightstr;
?>
</span>
15,在“最近查看果的产品”中显示添加产品的图片:
/var/www/magento.com/app/design/frontend/base/default/template/reports/product_viewed.phtml
<?php if ($_products = $this->getRecentlyViewedProducts()): ?>
<div class=”block block-list block-viewed”>
<div class=”block-title”>
<strong><span><?php echo $this->__(‘Recently Viewed Products’) ?></span></strong>
</div>
<div class=”block-content”>
<ol id=”recently-viewed-items”>
<?php foreach ($_products as $_item): ?>
<li class=”item”>
<p><a href=”<?php echo $this->getProductUrl($_item) ?>”><img class=”product-image” src=”<?php echo $this->helper(‘catalog/image’)->init($_item, ‘small_image’)->resize(56, 56) ?>” width=”56″ height=”56″ alt=”<?php echo $this->htmlEscape($_item->getName()) ?>” /> </a></p>
<p class=”product-name”><a href=”<?php echo $this->getProductUrl($_item) ?>”><?php echo $this->helper(‘catalog/output’)->productAttribute($_item, $_item->getName() , ‘name’) ?></a></p>
</li>
<?php endforeach; ?>
</ol>
<script type=”text/javascript”>decorateList(‘recently-viewed-items’);</script>
</div>
</div>
<?php endif; ?>
16,修改左边菜单缩略图也可以链接到类别:
/var/www/magento.com$ sudo geany app/code/community/Codnitive/Sidenav/Block/Navigation.php
//$html[] = $image;
$html[] = ‘<a ‘ . $aClass . $onclick . ‘href=”‘ . $this->getCategoryUrl($category) . ‘”‘
. $linkClass .’>’.$image.'</a>’;
17,判断是不是在首页
if(Mage::app()->getRequest()->getRouteName() == ‘cms’ && Mage::getSingleton(‘cms/page’)->getIdentifier() == ‘home’) {
}
18,修改注册页面的字段
在数据库中:
UPDATE `magento.com`.`eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` =22;
UPDATE `magento.com`.`eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` =7;
UPDATE `magento.com`.`customer_eav_attribute` SET `validate_rules` = ‘a:2:{s:15:”max_text_length”;i:255;s:15:”min_text_length”;i:0;}’ WHERE `customer_eav_attribute`.`attribute_id` =7;
UPDATE `magento.com`.`customer_eav_attribute` SET `validate_rules` = ‘a:2:{s:15:”max_text_length”;i:255;s:15:”min_text_length”;i:0;}’ WHERE `customer_eav_attribute`.`attribute_id` =22;
去掉验证信息:
/var/www/magento.com/app/code/core/Mage/Customer/Model/Address/Abstract.php
/var/www/magento.com/app/code/core/Mage/Customer/Model/Customer.php
/*
if (!Zend_Validate::is( trim($this->getLastname()) , ‘NotEmpty’)) {
$errors[] = Mage::helper(‘customer’)->__(‘The last name cannot be empty.’);
}
*/
移除lastname:
/var/www/magento.com/app/design/frontend/base/default/template/customer/widget$ sudo geany name.phtml