Magento,将产品名称传递给联系表单 [英] Magento, passing product name to contact form

查看:211
本文介绍了Magento,将产品名称传递给联系表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Magento初学者的你好,我对字词和名字的知识很差,但我会尽力解释这一点。



m目前正在配置 Magento联系表单,以便在产品视图页上从用户处收集一些数据。

更有趣的是,表单还将发送有关管理员放置的产品的一些数据,具体产品名称

并非所有产品都具有此表单,只有可用于供应的产品

我将Magento联系表单复制到我的 Layout-> Templates-> contact-> form.phtml 。嵌入到其中一个产品页面,输入:

Magento管理面板 - 目录 - 管理类 - OneOfTheProducts-edit- 自定义布局更新 code>

folowing reference xml:

 < reference& 
< block type =core / templatename =customer_request
template =contacts / form.phtml/>
< / reference>

测试它,它的工作原理,仍然管理员必须做这个xml放置在许多产品自定义布局更新文本框,但这不是这个问题的一部分。

Magento表单有以下字段:名称,电子邮件,电话,评论。

但是我需要发送一个参数到 postAction 的操作Mage_Contacts_IndexController ,这就是产品名称。



b> QUESTION

如何从产品页面获取联系人表单中的产品名称,此子块元素是否知道正在嵌入的页面内容?在Magento中有一些全局函数我可以使用和如何传递这个参数到控制器,我应该使用隐藏的输入字段还是...?



任何引用或代码段对我来说意味着一个世界。

解决方案

解决方案 >

form.phtml 中将此代码段添加到新的隐藏字段值,它检索当前页面的URL键/值,然后它加载传递值id的模型对象:

 <?php $ productId = $ this-> getRequest() - > getParams(); 
$ model = Mage :: getModel('catalog / product');
$ _product = $ model-> load($ productId [id]);
echo $ _product-> getName(); ?>

向引用该隐藏字段值的电子邮件模板添加了新的var,
也是这部分代码将是很好的候选人被放置在助手类。


Hello from Magento beginer,i'm poor in knowledge of terms and names but i will try hard to explain this as much clear as i can.

I'm currently working on configuration of Magento Contact Form to be able to collect some data from users on Product View Page.
To be more interesting, the form will have also to send some data about the product on which page admin puts it, concretely Product name
Not all products will have this form, only products that are available for supply in different (currently unavailable) colors and sizes.
I copied Magento Contact Form to my Layout->Templates->contact->form.phtml. Embedded it in one of the products page, putting in :
Magento Admin Panel-Catalog-Menage Categories-OneOfTheProducts-edit-Custom layout update

folowing reference xml:

<reference> 
  <block type="core/template" name="customer_request"  
   template="contacts/form.phtml"/>
</reference>

Tested it and it works, still admin has to do this xml placing in many products Custom layout update text box, but that's not part of this question.
Magento form has following fields: name, email, telephone, comment.
However i need to send one more parameter to postAction action of Mage_Contacts_IndexController, and that is Product name.

QUESTION
How can i obtain Product name in Contact form from Product page, can this child block element be aware of Page content in which is being embedded? Is there some global function in Magento i can use and how to pass this parameter to controller, should i use hidden input field or else...?

Any reference or code snippet will mean a world to me

解决方案

Solution

In form.phtml added this snippet of code to new hidden field value, it retrieves URL key/values of the current page, then it loads model object passing the value of "id":

<?php $productId=$this->getRequest()->getParams();   
$model = Mage::getModel('catalog/product');  
$_product = $model->load($productId["id"]);   
echo $_product->getName(); ?>

Added new var to email template referencing that hidden field value, also this part of code will be good candidate to be placed in helpers class.

这篇关于Magento,将产品名称传递给联系表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆