如何显示地区特定产品magento?

时间:2015-08-03 06:08:18

标签: magento magento-1.9 product region magento-1.9.1

  

如何根据选定的州和城市在Magento展示产品?是   有没有可用于此功能的扩展?或者我怎样才能实现   此?

1 个答案:

答案 0 :(得分:2)

您可以在产品型号中添加一个(城市)或两个(州和城市)属性(通过后台面板)。

您的新闻属性可以包含列表(带有分隔符逗号的示例字符串)以及允许销售该产品的州/城市列表。

要检索州/城市允许列表,您可以:

<?php 

// id product is 12345
// the city allowed list attribute code is 'city_list'

$id = 12345;
$product = Mage::getModel('catalog/product')->load($id);

$cityList = $product->getAttributeText('city_list');

var_dump($cityList);

输出如下内容:

string(38) "Los Angeles, New Delhi, Caen, etc, etc"

如果->getAttributeToSelect('city_list')模型无法检索该属性,您可能会在load($id)之后添加catalog/product