【问题标题】:is it possible to show custom attributes of associated products under a grouped product in front end? (Magento)是否可以在前端的分组产品下显示关联产品的自定义属性? (马金托)
【发布时间】:2012-01-06 07:12:03
【问题描述】:

我的 magento 分组产品有一个典型情况。 是否可以在前面的分组产品下显示关联产品的自定义属性(颜色下拉列表)。如下所示

考虑样品毯产品

如果我不清楚,请告诉我。 谢谢

【问题讨论】:

    标签: magento


    【解决方案1】:

    你的问题不清楚,但我会给你一个小例子来获取文本字段、多选或下拉列表框值。

    首先,我们应该加载产品集合:

    <?php
       // load the product that id 125, then show attributes of the product
       $product = Mage::getModel('catalog/product')->load($this->getProduct()->getId(125));
       echo $product->getCustomAttribute();
    
       // lets say your custom attributes name is "size" and type is text field
       echo $product->getSize();
    
       // lets assume your custom attributes name is "product_size then
       echo $product->getProductSize();
    
       // lets assume your attribute type is drop-down, this will get array of attribute options instead of value that you selected
       echo $product->getAttributeText(product_size);
    
       // to get drop-down value that you selected
       $attribute = $product->getAttributes();
       $productSize = $attribute['product_size']->getFrontend()->getValue($product);
    

    如果不符合您的要求,请告诉我。

    【讨论】:

    • 感谢 Oğuz Çelikdemir... 我将尝试使用此代码来获取自定义属性。但是,当用户在下拉菜单中选择特定颜色并将产品添加到购物车时...选择的颜色信息存储在购物车中吗?还是我必须进一步定制才能实现它..?
    • @balanv 当然,您应该自定义代码以查看购物车中的属性。我有一个小样本,但我应该看看它在哪里。
    • 当我为分组产品下的关联产品创建自定义属性时……我为其创建自定义属性的关联产品从前端消失了……默认情况下,magento 是否会阻止产品使用自定义属性显示在分组产品下..??
    【解决方案2】:

    我已经找到了一个解决方案,3 个编辑过的文件。 但是这些文件是为以前版本的 Magento 编辑的,我不知道是哪个版本。 我已经在我的 Magento 1.7 上上传了这 3 个文件,它可以工作,但是当将产品添加到购物车时,它给出了一个错误 app/code/core/Mage/Sales/Model/Quote.php

    这个文件:Quote.php 是编辑后的文件之一,当我上传原始的 Quote.php 时它可以工作。

    看这张照片:http://s8.postimage.org/g8bvbth0z/Naamloos.png

    但也许我将来会遇到更多错误,我没有任何想法..

    我是一个菜鸟,如果有人可以查看编辑过的文件并检查他们是如何做到这一点的,并将其与 Magento 1.7 的最新文件进行比较,也许我们可以帮助很多人解决这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 2010-11-03
      • 2012-04-07
      • 1970-01-01
      • 2014-02-10
      • 2021-01-31
      相关资源
      最近更新 更多