php – 获取magento中的产品ID
发布时间:2020-12-13 17:35:15 所属栏目:PHP教程 来源:网络整理
导读:在magento中,我想添加快速查看功能,像这个 http://www.timberlandonline.co.uk/on/demandware.store/Sites-TBLGB-Site/default/Link-Category?cgid=men_footwear_boots.我添加了一个隐藏的输入一个div在list.phtml.If我点击任何产品的div javascript返回该类
在magento中,我想添加快速查看功能,像这个
http://www.timberlandonline.co.uk/on/demandware.store/Sites-TBLGB-Site/default/Link-Category?cgid=men_footwear_boots.我添加了一个隐藏的输入&一个div在list.phtml.If我点击任何产品的div javascript返回该类别页面中的第一个产品的产品ID.但它应该返回所选div的产品ID.
您需要仔细查看此页面(< path_to_your_template_folder> /template/catalog/product/list.phtml).您将在此页面的不同位置找到以下代码行:
$_productCollection = $this->getLoadedProductCollection(); foreach ($_productCollection as $_product): $reqProductId = $_product->getId(); endforeach; 如果您仔细匹配上述代码&在上述页面中的代码中,您将知道您需要在“隐藏”类型的所需“INPUT”元素中正确使用变量“$reqProductId”.所以你需要它在主要的“foreach”循环中完成你的工作. 希望有帮助 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |