关键词:
【中文标题】获取magento类别view.phtml的特定属性【英文标题】:Get specific attribute on magento category view.phtml 【发布时间】:2012-08-22 14:28:47 【问题描述】:我正在尝试在我的 Magento 类别页面上创建一个 Asos 样式的标题。
在这个框中,我已经拉入了类别标题和类别描述,我还有些需要从分层导航中拉入特定属性到类别 view.phtml 页面中。
目前有
<?php $prod = Mage::getModel('catalog/product')->load($productId);
$att = $prod->getResource()->getAttribute('product')->getFrontend()->getValue($prod);
echo $att;
?>
但它只是拉入单词No
,而不是它在此特定类别的分层导航中显示的属性。
【问题讨论】:
你得到了value
的属性No
【参考方案1】:
试试这个:
Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
感谢@Daniel Kocherga 的原始答案here。
【讨论】:
我刚刚把它改成了那个,但现在什么都没有被拉进来,应该只是<?php Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'product', $storeId); ?>
还是我必须以某种方式回应它?
这似乎没有什么不同我现在有<?php echo Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'product', $storeId); ?>
更多的想法?如果有帮助,我正在使用 1.7.0.1。
我虽然必须将'attribute_code'参数更改为我想要显示列表的属性?我已经改回来了,但还是没有显示?
是的,您是对的,我只是没有在您发布的代码中看到它,我会尽快查看 :)
让我们continue this discussion in chat【参考方案2】:
来自 code/core/mage/catalog/block/product/view/attributes.php
public function getAdditionalData(array $excludeAttr = array())
$data = array();
$product = $this->getProduct();
$attributes = $product->getAttributes();
foreach ($attributes as $attribute)
// if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined() && !in_array($attribute->getAttributeCode(), $excludeAttr))
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr))
$value = $attribute->getFrontend()->getValue($product);
if (!$product->hasData($attribute->getAttributeCode()))
$value = Mage::helper('catalog')->__('N/A');
elseif ((string)$value == '')
$value = Mage::helper('catalog')->__('No');
elseif ($attribute->getFrontendInput() == 'price' && is_string($value))
$value = Mage::app()->getStore()->convertPrice($value, true);
if (is_string($value) && strlen($value))
$data[$attribute->getAttributeCode()] = array(
'label' => $attribute->getStoreLabel(),
'value' => $value,
'code' => $attribute->getAttributeCode()
);
return $data;
很确定这是用您的属性显示“否”或“不适用”的负责部分
【讨论】:
【参考方案3】:我不确定,但请参阅下面的 URL。我认为这对你很有帮助。
如何在类别中的产品网格中添加属性
http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/add-attributes-to-product-grid
Magento 属性:每个类别使用不同的可过滤属性
http://www.human-element.com/Blog/ArticleDetailsPage/tabid/91/ArticleID/68/Magento-Attributes-Using-Different-Filterable-Attributes-Per-Category.aspx
在产品页面上获取 Magento 类别属性的数据
http://spenserbaldwin.com/magento/get-data-for-new-magento-category-attribute
【讨论】:
另见隐藏指定类别中的属性magentocommerce.com/boards/viewthread/215030/#t296077 阅读netismine.com/magento/get-sort-category-children-as-collection 阅读imagedia.com/2010/02/…magento-打印一个类别navi,隐藏特定的类别
Manuallyprintoutacategory-navigationinamagentofrontendtemplate.within"stristr"youcanenteranarrayofcategory-idsthatshouldbehiddenfromdisplay.<?php$_menu=$this->renderCategoriesMenuHtml& 查看详情
某些产品的页面magento出现错误500(代码片段)
...的信息(OK页面和noOK页面上的相同错误)。日志是空的。Magento1.9.2.1。答案500是PHP错误所以请检查view.phtml文件找出错误。另一答案作为建议:启用Magento系统的调试模式。1)在index.php中取消注释这一行:#ini_set('display_errors',1);并... 查看详情
获取magento类别的url
ThiswillreturntheURLforthecategoryspecified(17inthiscase)Mage::getModel('catalog/category')->load(17)->getUrl(); 查看详情
Magento 获取子类别/类别集合处理。编程效率
】Magento获取子类别/类别集合处理。编程效率【英文标题】:Magentogetchildcategories/categorycollectionhandling.Programmingefficiency【发布时间】:2014-06-2306:46:48【问题描述】:好的,我在下面编写的代码效果很好,但是我有一些页面可能会... 查看详情
php获取magento类别的url(代码片段)
获取magento中的所有类别
privatefunctiongetCategories(){ $categories=Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter(); $all=array(); foreach($categoriesas$c){ $all[$c->getId(... 查看详情
显示特定类别的magento新产品(代码片段)
我需要在magento特定类别中显示新项目。我已经找到:blocktype="catalog/product_new"name="home.catalog.product.new"alias="product_new"template="catalog/product/new.phtml"但它显示了商店范围内的商品,并且还发现:blocktype="catalog/product_list"category_id="Category... 查看详情
Magento:从最低订单金额中排除类别
】Magento:从最低订单金额中排除类别【英文标题】:Magento:excludecategoryfromminimumorderamount【发布时间】:2016-02-1115:23:54【问题描述】:是否可以从Magento的最低订购量中排除某个类别?客户需要每个产品的最低订购量(最低订购量... 查看详情
php从主类别中获取magento子类别列表(代码片段)
Magento - 按属性分类产品
】Magento-按属性分类产品【英文标题】:Magento-categoryproductsbyattribute【发布时间】:2013-06-2922:11:58【问题描述】:当我在Magento中创建类别时,我目前手动添加所有产品。问题是我们的产品越来越多,而且我们的一些产品经常更换... 查看详情
Magento : 通过特定的付款方式获取订单
】Magento:通过特定的付款方式获取订单【英文标题】:Magento:Getordersbyspecificpaymentmethod【发布时间】:2013-02-2108:20:13【问题描述】:我如何使用付款方式“checkmo”来收集订单?可以用addFieldToFilter函数吗?谢谢。【问题讨论】:【... 查看详情
magento 从类别中获取产品,按 rand() 排序
】magento从类别中获取产品,按rand()排序【英文标题】:magentogetproductsfromcategory,orderbyrand()【发布时间】:2011-05-2008:28:25【问题描述】:我有以下几点:$products=Mage::getModel(\'catalog/product\')->getCollection()->addAttributeToSort(\'id\',\'RAND... 查看详情
所有产品(类别和子类别产品)都计入 magento 中的类别列表页面
】所有产品(类别和子类别产品)都计入magento中的类别列表页面【英文标题】:Allproducts(categoryandsubcategoryproducts)countoncategorylistpageinmagento【发布时间】:2014-03-1607:00:34【问题描述】:我想显示类别和子类别下所有产品的计数。... 查看详情
magento添加分层导航
Insertuptotheendoftocmspageandthesecondhalftothecustomlayout<divclass="category-head"><h2>Motoimage</h2></div>blocktype="catalog/product_list"category="4"template="catalog/product/list.phtml"<!--content--> <referencename=&... 查看详情
了解 Magento 块和块类型
】了解Magento块和块类型【英文标题】:UnderstandingMagentoBlockandBlockType【发布时间】:2011-10-0118:37:54【问题描述】:我只是想明白它的意思<blocktype="page/html"name="root"output="toHtml"template="example/view.phtml">我从Google获得了很多参考资... 查看详情
在magento中获取子类别
Oneapproachtogetallchildcategoriesofamagentocategory.<?php $category_model=Mage::getModel('catalog/category');//getcategorymodel$_category=$category_model->load($categoryid);//$categoryidforwhichthechildcategoriestobefound$all_child_categories=$category_model->getResour... 查看详情
Magento 工具栏不呈现寻呼机
】Magento工具栏不呈现寻呼机【英文标题】:Magentotoolbarnotrenderingpager【发布时间】:2013-04-1019:52:25【问题描述】:我是Magento的新手,当从catalog/category/view.phtml文件调用时,我很难弄清楚如何在工具栏中显示寻呼机。这是我正在使... 查看详情
Magento Commerce (Enterprise) 2.4 奖励在兑换时不包括类别
】MagentoCommerce(Enterprise)2.4奖励在兑换时不包括类别【英文标题】:MagentoCommerce(Enterprise)2.4RewardsexcludecategorywhenRedeeming【发布时间】:2021-10-0914:09:02【问题描述】:magento企业版包含一个集成的奖励积分模块。如何修改此模块以允许... 查看详情