magento custom form on product page - php

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.

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.

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.

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

Related

Wordpress ask user's their desired role as a dropdown menu while registration

I want to add a custom field to the Wordpress registration form without using any plugins. I want to add a dropdown menu with user-roles ( some roles I have created). Once the registration is complete the user should not have the ability to change their roles ( only admin can do that, selecting role as admin should not be allowed).
Any help will be appreciated.
I understand that you do not intend to use plugins, but you nevertheless use a theme, be it implemented by your team or some widely available theme. In any case, that theme has an implementation for your registration, so:
Find the registration form
Make sure that you find out where the registration form is.
Add a field to the form
Be it in a CMS editor or in a PHP/HTML file you must be able to edit it and add a field
Find the code which runs when a registration is posted
Again, you need to seek and find.
Enhance your functionalities which save fields
You will need to track and save the posted value
Change the database schema
You will need to do some changes on the MySQL schema in order to support the new field on database-level.

Wordpress - Hide specific fields to certain user role on back end

Is there a way in which I can disable/hide specific fields from the "page form" in the back-end? I have currently test two plugins but none of them meet the requirement that I have, like for example this plugin "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
I'm sorry that the options are in spanish but the capabilities options are for example: "edit pages", "edit other people's pages", "publish pages", "delete pages"... What I want is to hide certain sections to the "editor" user role from the page form:
Is this even possible?, and if not, what alternatives do I have?, the thing is that I'm afraid that whoever is in charge of editing will end up messing up with the pages...
Use Adminimize plugin It will resolve problem easily.
This plugin changes the administration back-end and gives you the power to assign rights on certain parts.
In most cases, the plugin "Adminimize" that Tech Sourav mentioned will work just fine, but since this page I'm working with is using some annoying custom content editor and other theme tools, the workaround that I ended up doing was:
Create a custom post type with the "Custom Post Type UI" plugin.
In this case I will only and always have 3 pages that have this "modifiable" price field, so once the custom post type is added I added 3 entries to this custom post type (here I will show you just one).
I'm also using the "advanced custom fields pro" plugin in order to create this price field into my entries.
When the custom field has been created there's this option inside the same previous form that allows me to show that specific field just created into specific post types entries, so I made up the rules in order to show this field in the created custom post type entries:
In this example I'm just showing you the rule for one entry, in order to make it appear on the other 2 entries, I would just click in the "agregar grupo de reglas" and select one by one.
Once this custom field and rules are configured correctly, I should see now the custom field "precio" inside my specified entries form:
After saving the entry with the updated custom field value, I will now check the post id and save it for later (we're going to need it):
According to the documentation of Advanced Custom Fields plugin I can show the saved value of certain input within certain post with the shortcode: [acf field="{$field_name}" post_id="{$post_id}"], in this case I will change the values to: [acf field="precio" post_id="1372"] and paste the code into the section of the page that I will show this:
The builder that this page is using has an element called "code block" but you can use it in the equivalent element that allows you to paste code from your theme.
After saving the changes, now the only thing that I have left is to restrict the ability to edit pages to a user with the "editor" role, for this I will use the plugin that I mentioned before in my question called "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
As you can see, I will not let editor users to mess up with the pages post types, so with this, they will only be able to edit the custom post type that I created, which even if they write something inside the content of that custom post type entry, the website won't be affected at all. This may be a little bit hacky but it works...

Add custom field to Magento Admin (URL field)

I'm trying to add a custom field in the Magento backend, at the Configuration -> Web section. I want to add an additional URL text space (can be in any of the sections, URL options, for example, would work well). How can I do that? I have seen other people who tried it by making a custom module, but that was for the category section. I need it at the Web section though, have not had success yet.
Thank you!
You can add an custom field to the web section. The best approach is to create a custom module for this.
In your system.xml you need to add your section to the Web section.
More information on this blog.
If you want to add attribute for product (can be text string named URL text) you can do it in catalog/attributes/manage attributes here you can create a new EAV attribute.
Next go to catalog/attributes/ manage groups/ and there you can drag/drop attribute to the correct group (will be shown in product admin page in the left list of groups)
In template you can call a attribute by call $_product->getAtributteName (if the attribute was named atributte_name) or $_product->getAnotherAttributeName (for attribute named another_attribute_name).
Always make sure if attribute is enabled for catalog / or product view you are using to make possible "get..." call from that view.
If you want it for using at URL, you can edit URL call by adding it to the end of URL as a GET parameter example:
http://www.somestore.com/?yourproductorcategoryurl&myparmforurl=<?php echo $_product->getSomeAtributteName ?>
if you using attribute type list (list of defined values, it always return an id of attribute value, not name) then you can use $_product->getAttributeText('name_of_your_attribute')
I was able to do this via the official Magento blog: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_add_a_custom_module_for_custom_admin_config_options
Thank you for your help though!

Add new page to Magento user account

I've been stuck on the proper way to do this for a while. I want to add a new page to the Magento user account on the front end after log in/creation. There is some information we would like to gather from our customers separate from account creation. The page needs to be dynamically generated, as it will pull information from the database, so CMS is not an option.
I know there's a template .phtml file I'll need to create. I also know where to override customer.xml to have the link show up.
But, I have NO idea how to make the page show up (I can add the link, but it goes to 404). I assume there's some sort of xml reference to associate url to file, and the template to use. If someone can point me in the right direction, I can probably reverse-engineer the format.
I also don't know how to properly use Magento's existing functions to grab the information on submit. I want to show the same page after submission, with info in fields ready to change. Can I/should I just use the same .phtml template file to process the form submit?
Thanks!
Create a custom phtml page with your desired functionality.
Create a cms page and call the .phtml page from within it as
follows,
{{block type="core/template" template=".../.../yourcustom.phtml"}}
3.Your problem solved.
I think you have a fair idea on how to handle the cms page to get your desired functionality.
You can customize the phtml file of account information page ../customer/account/edit/
but to force filling this form you need to make module and add observer controller_action_predispatch and add method that check for the data you want and if not redirect them to the account information page

Adding values to a magento dropdown or multi-select product attribute while adding a new product

I'm wondering if anyone has found or written an extension that would allow a magento website administrator the ability to add values to their products attribute while adding the product. For example, if I sell books and want the book author to be in a drop down list so that it would be used in layered navigation, it seems odd that I would have to add the author via the attributes section before adding the product. From a workflow standpoint it really makes sense to have an "add new value" button next to the drop down on my add product screen.
Anyone have any thoughts or insight?
It's a piece of cake to do, if you know jquery and the (if I may guess) extremely simple model behind magento.
As the other guy said, throw some money and I'll do it ;)
Otherwise, real easy -> find where that dropdown is generated, add a button next to it that opens a popup which you fill "create a new thingie" stuff, create button -> +create +close +refresh your dropdown.
Definitely easy.
And considering the attribute dialog already exists in the tool you cold probably take most from there and just add the popup handlers / button / +refresh .
This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, import images and media galleries, reindex, refresh cache, media and price rules automatically. In addition you can backup the entire database in SQL format.
So from above, once you make the csv file, you just have to add the Author header and it would build the list from there. However, the attribute must exist first. I am using this method for the creation of my own manufacturer attribute options.
AMartinez_CustomImportExport
Can't say I have, but I've developed something similar that creates an attribute and adds it to multiple products, it's completely possible, you just need to add something that will call the add attribute on the add product page or change the new product flow to allow a new attribute and add it if needed.
Don't let them scare you, it's not as hard as some people might describe :)
My curiosity finally took over my laziness and I managed to create the module author requested. It's available on github.
Please feel free to check it out and update it if you wish. Maybe in some near future I'll post it on Magento Connect, if feedback is good.
Here's some code that checks if an attribute value exists and adds it if it doesn't: http://www.magentocommerce.com/boards/viewthread/26234/
Shouldn't be too hard to integrate it with the "Add product" form.

Categories