magento -- 移动产品页选项和购买按钮到简介下方

来源:互联网 发布:iapp魔盒源码大全 编辑:程序博客网 时间:2024/06/08 06:15

Magento的产品页显示自定义选项或可配置产品的配置项在模板文件里都是归类于Options,默认模板下这一块会显示在产品信息的下方,如图

这个位置很多人觉得并不好看或合理,想要把它挪到图片的右边,也就是Quick Overview所在的位置,如下图

打开后台产品页,找到Design下的Display product options in属性,可以看到两个选项:Product Info Column和Block after Info Column,其中默认选中的是Block after Info Column,从字面意思就可以理解,Options的内容默认是显示产品信息的下方,如果把该产品的Display product options in属性设置为Product Info Column,前台就会看到第二张图片的效果。

也就是说,Magento系统本身就为这一块提供了两种显示位置,通过修改后台的属性值可以选择使用哪种位置,不过问题来了,如果我希望所有产品的Options内容默认都显示在Product Info Column,而不用所有产品一个个打开去改属性,那就需要修改代码来实现了。

打开产品页的主模板文件view.phtml,可以看到两端类似的代码

view plaincopy to clipboardprint?
  1. <?php if ($_product->isSaleable() && $this->hasOptions()):?>  
  2.     <?php echo $this->getChildChildHtml('container1''', true, true) ?>  
  3. <?php endif;?>  

 

view plaincopy to clipboardprint?
  1.               <?php if ($_product->isSaleable() && $this->hasOptions()):?>  
  2.     <?php echo $this->getChildChildHtml('container2''', true, true) ?>  
  3. <?php endif;?>  

 

这两段就分别是Product Info Column和Block after Info Column两个位置,从代码在view.phtml里的位置就可以看出,也就是说后台默认是Block after Info Column的情况下,信息会显示在container2里。现在剪切container2这段代码,把它放到和container1同一个位置,这样,产品新加完默认情况下Options就会显示在第二张图片显示的位置了,模板文件里最后的代码如下

view plaincopy to clipboardprint?
  1. <?php echo $this->getChildHtml('other');?>  
  2.              <?php if ($_product->isSaleable() && $this->hasOptions()):?>  
  3.             <?php echo $this->getChildChildHtml('container2''', true, true) ?>  
  4.         <?php endif;?>  
  5.             <?php if ($_product->isSaleable() && $this->hasOptions()):?>  
  6.                 <?php echo $this->getChildChildHtml('container1''', true, true) ?>  
  7.             <?php endif;?>  

 

 

原创粉丝点击