获取magento的产品ID

bla*_*aps 8 php magento

在magento,我想添加这样的快速浏览功能http://www.timberlandonline.co.uk/on/demandware.store/Sites-TBLGB-Site/default/Link-Category?cgid=men_footwear_boots.我添加了一个隐藏输入和list.phtml中的div.如果我点击任何产品的div,javascript返回该类别页面中第一个产品的产品ID.但它应该返回所选div的产品ID.

Kno*_*ing 16

您需要仔细查看此页面(<path_to_your_template_folder>/template/catalog/product/list.phtml).您将在本页的不同位置找到以下代码行: -

$_productCollection = $this->getLoadedProductCollection();

foreach ($_productCollection as $_product):
    $reqProductId = $_product->getId();
endforeach;
Run Code Online (Sandbox Code Playgroud)

如果您仔细地匹配上述代码和上述页面中的代码,您将知道您需要在" $reqProductId"所需的" INPUT"元素中正确使用变量" hidden".所以你需要它在主foreach循环中扮演你的角色.

希望能帮助到你.