5

I'm new to Magento, and i need some conceptual guide and/or references. I need to create custom form that will be a part of product-info page (at it's bottom) and that will collect user input (email, size, color). Only some product will have this feature/form (it's up to admin). So, goal of this form will be to email store-admin about a product that is available in stock but not in wished size and/or color. Should i customize existing Contact us form or should i create fresh custom form in new module?
Form should submit data to admin via email along with name of the product.

maljukan
  • 2,148
  • 2
  • 25
  • 35
  • If you accept, I can offer only email option. I haven't got much time to write admin section code to show sent it by customer! – Oğuz Çelikdemir Jan 22 '12 at 14:59
  • @Oğuz Thx (Teşekkür ederim :)), that would help a lot! – maljukan Jan 22 '12 at 15:55
  • rica ederim :) ( means your welcome ) – Oğuz Çelikdemir Jan 22 '12 at 17:47
  • @Oğuz I'm currently trying to write code for custom email form, can you give me a hint how to get product Name so i could use it in email content or should i ask that in another question? – maljukan Jan 23 '12 at 15:38
  • you can use custom variables in email templates. Check admin > system menu. check this links [Defining Transactional Variables](http://go.magento.com/support/kb/entry/name/defining-transactional-variables/) or [Transactional Emails](http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/system_email_template/index) – Oğuz Çelikdemir Jan 23 '12 at 22:31
  • @Oğuz I saw how to use custom vars but i don't know how to get product name into the form so i can send it to sendEmail action as hidden field. I can't find solution for this nowhere. :( – maljukan Jan 26 '12 at 18:33
  • check this out [Advanced Tracsactional Email Templates](http://www.excellencemagentoblog.com/magento-advanced-transactional-email-templates) – Oğuz Çelikdemir Jan 26 '12 at 18:52
  • @Oğuz Oh this will be a challenge, thanks for everything IronMan :) – maljukan Jan 26 '12 at 19:47
  • @Oğuz Solved it :) http://stackoverflow.com/questions/9011499/magento-passing-product-name-to-contact-form – maljukan Jan 27 '12 at 00:36

3 Answers3

1

Sounds like you'll need a custom form. You'll need a new database table to store the data, a Model to represent the data, and a controller to post the form to at the very least. You'll probably want to add an attribute to Products which is a yes/no of whether to display the form. You'll also probably want to view the data, so you'll have to make pages in the admin site. Perhaps a grid of all answers and a page to view/edit a specific answer.

Max
  • 8,671
  • 4
  • 33
  • 46
  • Ohh, i've forgot to mention that the form should submit data to admin via email so there's no need for db. Form should also be aware of it's parent product page so that it can send name of that product. Sorry for missing that. – maljukan Jan 22 '12 at 14:53
  • Thats OK. In that case, you can ignore the DB parts and Admin section. You still need a url to post to and code that will take the post and convert the data into an email that is sent. If you don't want to write that code yourself you could use a service like http://wufoo.com/ or the like, but if you want to do it yourself then you will have to make a simple module. I highly recommend reading the first few articles at http://alanstorm.com/category/magento for a good tutorial on building modules. – Max Jan 22 '12 at 15:17
  • Thank you Max, i'm sorry i could not make both answers accepted, your link helped me in a great way. That is one hell of a tutorial. You sad that i still need a url to post to and code that will take the post and convert data into an email, but doesn't it mean that i will redirect to another page after submitting the form? Do you want me to form that in another question and invite you? – maljukan Jan 24 '12 at 22:34
  • Naa its OK - To redirect to a different page you do a redirect command at the end of the `controller`. To redirect to the page that submitted the form do, do `$this->_redirectReferer();`. Otherwise do `$this->_redirect('module/controller/action')` to go to a different page. Look up the function `getUrl` to learn about the `module/controller/action` part of the redirect. – Max Jan 25 '12 at 07:09
  • Thx for everything, helped me a lot – maljukan Jan 25 '12 at 20:17
1

Ok, so first create a .phtml file under app/design/frontend/[namespace]/[theme]/template/catalog/product/send_request.phtml

then, add this .phtml file reference in catalog.xml in /app/design/frontend/[namespace]/[theme]/layout/catalog.xml

<block type="core/template" name="customer_request" template="catalog/product/send_request.phtml"/>

below the : <label>Catalog Product View (Any)</label>

section but you should find to right section where to place ( you will find after a few try )

Finally, add your php logic into send_request.phtml file. The form contain that you implemented in send_request.phtml will available under product view page.

Oğuz Çelikdemir
  • 4,990
  • 4
  • 30
  • 56
  • Finally made it work :) Just used default Contact form and copied it with it's path to my layout path. However there was a problem with double quotes when updating layout catalog. I did debugging and find out that email is being sent only when i replace double to single quotes. You may update you'r answer if you find out that this is a regular issue. – maljukan Jan 25 '12 at 20:28
0

There is a free extension available. You can use this extension and customize it according to your needs. Product Questions

Earlee
  • 338
  • 4
  • 17
Sarath Tomy
  • 504
  • 4
  • 12
  • Link to magento connect is dead again. However, you may refer to the [github repository](https://github.com/magebuzz/Magebuzz_ProductQuestion) of the extension. – Earlee Sep 20 '17 at 05:51