gpt4 book ai didi

php - 通过自定义页面中的url获取产品ID?

转载 作者:行者123 更新时间:2023-12-02 18:23:41 26 4
gpt4 key购买 nike

我遇到了这个问题,无法解决。部分原因是我无法用正确的术语来解释它。我是新手,很抱歉提出这个笨拙的问题。

下面您可以看到我的目标的概述。

我在我的 magento 中创建了一个自定义模块,它工作得很好。

使用这个我创建了那个 http://www.phparrow.com/magento/magento-create-a-simple-module/

在我的产品页面中我有一个链接

<a href = "http://www.example.com/magenaresh/index.php/hello/ "> Click Here </a>

当我点击点击此处时,它会重定向到 http://www.example.com/magenaresh/index.php/hello/ 这个 URL 到这里一切都很好...

但现在我想传递 ProductID 和 URL

为此我这样写

<?php 
$product_id = $this->getProduct()->getId();
echo $product_id;
?>

<a href = "http://www.example.com/magenaresh/index.php/hello/<?php echo $product_id ?> ">Click Here</a>

我再次点击Click Here它的显示

enter image description here

我在这里做错了什么吗?

有什么想法吗?

最佳答案

您可以在 href 处添加链接,例如

<a href = "http://www.example.com/magenaresh/index.php/hello/index/index/product_id/<?php echo $product_id ?> ">Click Here</a>

并且在您的 Controller 中可以以与以前完全相同的方式访问 URL 参数;

$id = $this->getRequest()->get('product_id');

希望这一定会对您有所帮助。

关于php - 通过自定义页面中的url获取产品ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18585004/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com