dtch60248 2012-07-05 13:26
浏览 39

可配置产品,选择框'值'字段。 Magento的

Having a problem with getting some data out of a configurable product, basically the 'standard' drop down select menu appears to select some as normal on my product page.

I'm doing something fiddly with an overlay and I'm going to be 'controlling' these select options using the jQuery .val() function.

The .val() function needs to take the tags 'value' field.

Now I can't find out how to pull this value when getting configurable product information...

I'm pulling information about the configurable products like follows:

    $attrs  = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
    foreach($attrs as $attr) {
        $options = $attr['values'];
        foreach($options as $option) {
            echo "<p class='swatchie' id='".$attr['attribute_id']."' title='".$attr[]."'>{$option['store_label']}</p><br />";
        }
    }

As you can see, the attr in title is blank as this is where I need to pull in the option value. the html magento gives for the option boxes looks like this:

      <option value="">Choose an Option...</option><option value="41" price="0">King</option><option value="42" price="540">Super King +£540.00</option></select>

I think I've found 'where' the value I need is located,

app/code/core/mage/catalog/model/resource/product/type/configurable/attribute/collection.php

Line 258,

                            $values[$item->getId() . ':' . $option['value']] = array(
                                'product_super_attribute_id' => $item->getId(),
                                'value_index'                => $option['value'],

Value index is what i think i want, no idea how to get hold of it though

Any ideas of how to pull this thorugh?

  • 写回答

1条回答 默认 最新

  • duanhuren5581 2012-07-20 05:29
    关注

    Use firebug to see the structure of the variable named 'spConfig', the data of configurable products can be found there.

    Kindly notice, the jQuery().val() won't trigger the select action defined by default Magento using prototype. Thus you may trigger the change action by prototype additionally.

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据