首页 > 其他分享 >magento 获取产品的属性值

magento 获取产品的属性值

时间:2023-04-03 23:36:27浏览次数:35  
标签:product getFrontend color getValue 获取 magento 属性


magento采用强大的EAV设计方法,我们可以很方便的给商品添加任意数量的属性,那如何在前台获取这些属性值呢?

 

magento同样提供了很方便的方式来读取它。使用$_product->getAttributeName ()或者$_product['AttributeName' ]就可以获得指定名字属性的值,以颜色属性color为例,可以这样写   $_product->getColor ()  or  $_product['color'

$_product->getResource()->getAttribute('AttributeName')->getFrontend()->getValue($_product)

同样以颜色为例:

$_product->getResource()->getAttribute('color')->getFrontend()->getValue($_product)

 

 

或者可以使用:

$_product->getAttributeText('attribute_code');  // string or array

 

 

标签:product,getFrontend,color,getValue,获取,magento,属性
From: https://blog.51cto.com/u_8895844/6167713

相关文章

  • magento 在产品页添加评论 Add Review Form in Magento Product View Page
    Magento产看产品评论需要点击到另外一个页面中,这种设计对于用户体验和SEO都相当不利。一方面用户无法在产品页面查看该产品的一些用户评价,另外,搜索引擎也会收录很多与产品无关的页面。那么如何让产品评论直接显示在产品页面呢?我们需要修改一下模板文件,很简单即可实现。 首先,在lay......
  • megento 获取url参数
    ifwehavethefollowingrequirement:http://host/index.php/?resid=anyvalue    http://host/index.php/storeviewname/?resid=anyvalue,or......?resid=anyvalue //getallParameters.$this->getRequest()->getParams()//getanyspecifically$this->ge......
  • magento 高级搜索 brand实例 Magento ‘Shop By Brand’ in SideBar
    高级搜索地址一般为:/catalogsearch/advanced/ Firstcreatethetemplatefileandnameitproductbrand.phtmlplaceitincatalog/productfoldercopythecodegivenbelowandpasteritinyouproductbrand.phtml Note:Pleasechnage‘yourdomain.com’withyoursit......
  • magento 问题解答 FQA
    1.IsthereawaybymysqltosetALLproductvisibilitytocatalog,search? 批量修改产品可见 openuptheeav_attributetableandfindtherowwhereattribute_code=visibility.Takenoteoftheattribute_id,mostlikelyitwillbe85.Alsotakenotetha......
  • 深入理解Magento – 第七章 – 自定义Magento系统配置
    深入理解Magento作者:AlanStorm翻译:HailongZhang第七章–自定义Magento系统配置Magento拥有十分强大的后台管理系统。作为一名开发人员,这套后台管理系统可以让你的用户简单直接的配置Magento系统或者你创建的模块。和Magento的其他功能一样,你第一次使用这套管理系统的时候可......
  • ArcEngine|按属性查询
    按属性查询界面设计思路该属性查询界面思路如下:首先选择按属性查询方法,并打开功能界面;接着在“图层”下拉框中选择图层;图层选择好后,可从“字段”中选择该图层对应的查询字段,并可查看该字段的唯一值;使用按钮输入SQL查询语句,并可在下方的文本框中查看输入的SQL语句;命令编写完成......
  • Spring 类型转换详解,SpringBean创建时属性类型转换源码详解
    文章目录一、概述1、Spring类型转换的实现2、使用场景3、源码分析二、基于JavaBeans接口的类型转换1、代码实例2、Spring內建PropertyEditor扩展ByteArrayPropertyEditor3、自定义PropertyEditor扩展整合到springframework代码实例SpringPropertyEditor的设计缺陷三、Spr......
  • eyoucms 获取单页内容的代码
    {eyou:typetypeid='你的栏目id'addtable='single_content'}{$field.content|html_msubstr=###,0,155}...{/eyou:type}(此标签过滤样式){eyou:typetypeid='你的栏目id'addtable='single_content'}{$field.content|getsubstr=###,0,420}........
  • vue指令之属性指令
    目录属性指令示例属性指令标签上的属性可以绑定变量,变量变化,属性也会变化#什么是属性?比如:href/src/name/value/class/style...语法:v-bind:属性名="变量名"简写:属性名="变量名"示例<body><divid="app"><av-bind:href="url">点我</a>......
  • Java 获取当前或调用者类名和方法名(Thread.currentThread().getStackTrace()、new Thr
    Java获取当前或调用者类名和方法名(Thread.currentThread().getStackTrace()、newThrowable().getStackTrace())原文链接:https://blog.csdn.net/inthat/article/details/111885544文章目录一、Java获取当前类名和方法名Thread.currentThread().getStackTrace()1.关于Thr......