Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在magento中获取产品id_Php_Magento - Fatal编程技术网

Php 在magento中获取产品id

Php 在magento中获取产品id,php,magento,Php,Magento,在magento中,我想添加如下快速查找功能。我在list.phtml中添加了一个隐藏输入&div。如果我单击任何产品的div,javascript将返回该类别页面中第一个产品的产品id。但它应该返回所选div的产品id。您需要查看此页面(/template/catalog/product/list.phtml)请仔细阅读。您只能在本页的不同位置找到以下代码行:- $_productCollection = $this->getLoadedProductCollection(); for

在magento中,我想添加如下快速查找功能。我在list.phtml中添加了一个隐藏输入&div。如果我单击任何产品的div,javascript将返回该类别页面中第一个产品的产品id。但它应该返回所选div的产品id。

您需要查看此页面(
/template/catalog/product/list.phtml
)请仔细阅读。您只能在本页的不同位置找到以下代码行:-

$_productCollection = $this->getLoadedProductCollection();

foreach ($_productCollection as $_product):
    $reqProductId = $_product->getId();
endforeach;
如果仔细匹配上述代码和上述页面中的代码,您将知道需要在所需的“
输入”
“隐藏”
类型的元素”
中正确使用变量“
$reqProductId
”。因此,您将要求它在主“
foreach
”循环中完成您的部分


希望有帮助。

尝试下面的代码以获取当前加载的产品id:

$product_id = $this->getProduct()->getId();
当您无权访问
$this
时,可以使用Magento注册表:

$product_id = Mage::registry('current_product')->getId();
我认为产品类型也是如此

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

$productType = $product->getTypeID();

谢谢。我将每个产品id存储在锚定标记的id中,并使用jquery获取id。我也将尝试这种方法。知道如何在管理面板/目录/管理产品中获取产品id吗?…您的URL指向404页。