服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

11个magento细节修改总结

时间:2013-12-08 00:06来源:未知 作者:最模板 点击:
1、magento快捷格式化商品价格: 1 !--?php echo Mage::helper(core)---currency($product-getPrice());? 2、格式化magento时间: 1 2 3 4 5 原始日期: ?php echo $timeLapseBegin ? Full Date: ?php echo Mage::helper(core)-format

1、magento快捷格式化商品价格:

 
1
<!--?php echo Mage::helper('core')--->currency($product->getPrice());?>

2、格式化magento时间:

 
1
2
3
4
5
原始日期: <?php echo $timeLapseBegin ?>
    Full Date: <?php echo Mage::helper('core')->formatDate($timeLapseBegin, 'full',true); ?>
    Long Date: <?php echo Mage::helper('core')->formatDate($timeLapseBegin, 'long',false); ?>
    Medium Date: <?php echo Mage::helper('core')->formatDate($timeLapseBegin, 'medium',true); ?>
    Short Date: <?php echo Mage::helper('core')->formatDate($timeLapseBegin, 'short',true); ?>

最后一个参数是’false’或’true’,是否显示时分秒。

3、快捷获取magento LOGO:

 
1
2
路径<?php echo Mage::getDesign()->getSkinUrl( Mage::getStoreConfig('design/header/logo_src')) ?>
ALT<?php echo Mage::getStoreConfig('design/header/logo_alt') ?>

4、用户中心菜单增删改:
删除:

 
1
unset($_links['tags']);

修改:

 $_links['address_book']['label']='我的地址簿';

$_links的所有’name’

account(账户显示板)
account_edit(账户信息)
address_book(地址薄)
orders(我的订单)
billing_agreements(记账协议)
recurring_profiles(循环设定档)
reviews(我的产品评价)
tags(我的标签)
wishlist(我的收藏)
OAuth Customer Tokens(我的应用程序)
newsletter(新闻邮件订阅)
downloadable_products(我的可下载产品)

5、添加删除一个系统Attribute

 增加:<?php $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $setup->addAttribute('customer', 'customcode', array( 'label'        => 'customcode', 'type'        => 'varchar', 'visible'    => true, 'required'    => false, 'sort_order' = > 10 )); ?>
删除:<?php $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $setup->removeAttribute('customer', 'customcode'); ?>
修改:$installer->updateAttribute('catalog_product','short_description','is_required',0);

6、Magento获取客户端IP:

 
1
2
// 返回Ip地址的字符串格式:127.0.0.1
echo Mage::helper('core/http')->getRemoteAddr();
 
1
2
// 返回Ip地址的数值格式:2130706433
    echo Mage::helper('core/http')->getRemoteAddr(true);

7、Magento: Get checkout cart total details | Subtotal/Grandtotal/Discount/Tax:

$totalItemsInCart = Mage::helper('checkout/cart')->getItemsCount(); //total items in cart
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = round($totals["subtotal"]->getValue()); //Subtotal value
$grandtotal = round($totals["grand_total"]->getValue()); //Grandtotal value
if(isset($totals['discount']) &#038;&#038; $totals['discount']->getValue()) {
    $discount = round($totals['discount']->getValue()); //Discount value if applied
} else {
    $discount = '';
}
if(isset($totals['tax']) &#038;&#038; $totals['tax']->getValue()) {
    $tax = round($totals['tax']->getValue()); //Tax value if present
} else {
    $tax = '';
}
获取订单地址信息:$order->getShippingAddress()->getData()
获取订单支付信息:$order->getPayment()->getData()
$order->getPayment()->getMethodInstance()->getCode()

8、Magento – 获取订单支付信息:

<?pph
$order_id = 2314; //use your own order id
$order = Mage::getModel("sales/order")->load($order_id); //load order by order id
$payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
//eg. checkmo
?>

9、获取网站基本信息:

Echo Store ID:<?php echo Mage::app()->getStore()->getId(); ?> 
Echo Store View Name: <?php echo  Mage::app()->getStore()->getName(); ?> 
Echo Store Group Name: <?php echo  Mage::app()->getStore()->getGroup()->getName(); ?> 
Echo Website Name: <?php echo  Mage::app()->getWebsite()->getName(); ?> 

10、获取订单状态:
$order->getStatusLabel()//状态名称
$order->getStatus()//状态代码
获取所有历史状态:

 <?php foreach ($this->getOrder()->getStatusHistoryCollection(true) as $_item): ?>
 $this->helper('core')->formatDate($_item->getCreatedAtDate(), 'medium')//操作时间
$_item->getStatusLabel()//状态名称
<?php if ($this->isCustomerNotificationNotApplicable($_item)): ?>//是否通知用户
                <?php echo $this->helper('sales')->__('Notification Not Applicable') ?>
                <?php elseif ($_item->getIsCustomerNotified()): ?>
                <?php echo $this->helper('sales')->__('Notified') ?>
                <img src="<?php echo $this->getSkinUrl('images/ico_success.gif') ?>" width="16" height="16" alt="" />
                <?php else: ?>
                <?php echo $this->helper('sales')->__('Not Notified') ?>
                <?php endif; ?>
//备注描述
 <?php if ($_item->getComment()): ?>
                <br/><?php echo $this->escapeHtml($_item->getComment(), array('b','br','strong','i','u')) ?>
            <?php endif; ?>
<?php endforeach; ?>

11、top.link的添加删除:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
添加:<action method="addLink" translate="label title">
                    <label>帮助中心</label>
                    <url>help</url>
                    <title>帮助中心</title>
                    <prepare>true</prepare>
                    <urlParams helper="core/url/getHomeUrl"/>
                    <position>555</position>
                    <liParams/>
                    <!--<aParams>class="top-link-about-us"</aParams>-->
                    <beforeText></beforeText>
                    <afterText></afterText>
                </action>
删除:1、<remove name="checkout_cart_link" />
2、<action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/></action>

(责任编辑:最模板)
顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容