Magento Custom Form in create order page - magento

I want to add custom form in create order page in magento admin side.As per my client request i was trying to create measurements form and wanna store data.I am new to magento.Please help me.Attached image for ref.
Already posted same question in Magento Stack Exchange My Question
I created block in layout/sales.xml file and created customform.phtml.Now i'm able to display custom form.Now i want to store data along with other data in this page.

You should add a table (with order id as foreign key) or a new text field to order sales_flat_order table.
After that, you are able to catch this event: sales_order_save_after
Inside this function, you can save data to the custom table or custom field you added.
good luck.

Related

Using ajax in prestashop custom module, retrieve data from an input field date to a module's FrontController for exploitation and SQL query afterwards

I need your help to understand how to retrieve the data from the product page form (product.tpl) sent by the 'add to cart' button (product-add-to-cart.tpl include).
Indeed, I would like to retrieve the value of a datepicker field, added under the entry dedicated to the quantity of the product page,
in order to save it in the ps_cart_product table.
Despite my research in the cart class and its controller, I can't do it. How to retrieve the value of an entry in the home page of a product?
A null date (0000-00-00) is however well recorded in our new columns date_retrait in ps_cart_product, we manage to recover it as you can see on a screen, but not to record it correctly.
Where can I call $_POST or REQUEST from the input datepicker name = date_retrait
(here it is 2022-07-24 but this is only a test, modified directly in the DB, normally it displays 0000-00-00)
I understood that I had to use Ajax (mymodule\/controller\/front\/ajax.php)
But I don't understand all the steps, what should I add/modify and especially: where (which files with path)?
[product_tpl][1]
[cart_popup][2]
[add to cart][3]
[ps_shoppingcart_js][4]
[1]: https://i.stack.imgur.com/MwLPS.png
[2]: https://i.stack.imgur.com/LjpMe.png
[3]: https://i.stack.imgur.com/3P4Y2.png
[4]: https://i.stack.imgur.com/z0eb4.png

How to add image field in dynamic input group for magento admin configuration setting?

I have created a module which add dynamic input group to magento admin configuration.
I have added image field but it can't save in database. Means if I select image than only image store in database in core_config_data — the encrypted value of row (just image field value)
If I remove image field than the data saved properly in database along with other inputs.
So here I can't save image type data with other data of dynamic input.
I've found reason + solution, maybe this is helpful for someone. Magento is using the wrong backend model. For saving images the backend model must be system_config_backend_image. But as you've added the fields dynamically (and not inside the system.xml) the fields have no assigned backend model, so magento will use the default for text values etc..
The solution is, to use the clone_fields functionality. Please find my explanation how to use it on my blog post http://www.mellority-report.com/magento-dynamic-config-fields-with-custom-backend-models/

How VirtueMart sends the data when you save the custom fields in a product

first of all, sorry for my english, but I'll try to explain myself best I can.
My question is little tricky, because I made some important changes in the core code of VirtueMart.
For some reasons, I added an attribute to the Custom Fields, like Price, called Availability.
TIP: The admin site is in Spanish. Disponibilidad = Availability
So, now, when I try to change any value of any created Custom Field, I can't save it. I mean, I can change the value, but when I apply them, It doesn't be saved.
The only field that I can change, is the field I created, the Availability (ironically).
So, my principal question is, how does VirtueMart to pick up the data from the table and sends them to the database?
I work with
Joomla v.2.5.11
VirtueMart 2
Thanks
The workflow is like follows,
When you save the products details on the backend , It calls a function store() on the product.php model. under administrator/components/com_virtuemart/models/. Inside this function an area like follows.
if(!class_exists('VirtueMartModelCustom')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'custom.php');
VirtueMartModelCustom::saveModelCustomfields('product',$data,$product_data->virtuemart_product_id);
It loading the custom model file from the same path and do the task inside saveModelCustomfields()
Hope it helps..

A panoply of queries about Magento databases

Through which file are new customers created and saved in Magento databases?
Which function is used?
Please provide me with full path locations and function names.
Also tell me about customer groups. From where and through which files/functions do customer groups get saved in Magento?
How are customers and customer groups related?
How can I "catch" customer IDs and customer group IDs from those files?
I find the file through which Magento saves New Customer-:
/magento/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
In the file CustomerController.php, there is a function saveAction() which saves a customer in Magento db.
I wanted to know how to catch Newly created customer's id(I guesss i.e. Entity Id in Customer_entity table for Magento db) from that CustomerController.php file.
I tried this but it won't work for me-"
$customer_data = Mage::getModel('customer/customer')->load($customer_id);
Anybody knows how to catch customer id while creation of new customer???
Try to search here:
Mage_Customer_AccountController->createPostAction
Well class name means
(root)/app/code/core/Mage/Customer/controllers/AccountControlller
Mage_Adminhtml_Customer_GroupController
Take a look at the AccountController.php at app/code/core/Mage/Customer/controllers, it will give you an idea how customer registration is processed.
Basically an instance of Mage_Customer_Model_Customer is created, proper data is assigned to it (collected from a post form on the registraton form or received via a webservice call) and the model is saved. The internal Magento mechanics work to put this data in proper db tables.
See also create function of the Mage_Customer_Model_Customer_Api class.
customer groups are created in Mage_Adminhtml_Customer_GroupController->saveAction(), the model being used is Mage_Customer_Model_Group
actually customer group is assigned from backend,by default general group is selected for customer group, if you want to get customer groups then you can use this code Mage::helper('customer')->getGroups()->toOptionArray();
Search for this file
/YourProject/app/code/core/Mage/Customer/controllers/AccountController.php
Search for this function name
public function createPostAction() //Magento saves New Customer
This above mentioned function is responsible for new customer registration.
print_r($this->getRequest()->getPost()); //get all the post data
print_r($session); //get all the session data

Magento - custom form

I have a form, which at the moment is a simple HTML based one, that doesn't do anything.
What I'm looking to do though, is to be able to send an email once the form has been submitted and also save the data to the database.
The problem comes, with the email sending. In the form, there is a drop down menu. The menu items are items in my suppliers model/module, which have a name and email address.
So, when I select Supplier A, the form passes validation, it needs to send Supplier A an email and save the details (this shouldn't be too hard).
I'm just not sure how I'd get the email address.
Would I need to pass some kind of parameter to a custom sendEmail() method?
All help appreciated.
Thanks
UPDATE:
Ok, so before I do the email part, I'd like to store the data in the table, named test drive.
I've created the module in the admin and a form to submit data from on the frontend end.
But I cannot seem to get the data to insert.
All help is welcome
Thanks
For sending email see this Mage_Contacts_IndexController::postAction() action or
Mage_Sales_Model_Order::sendNewOrderEmail()
If You created module with model, you can get instance of that model, insert data and then save it or You can create ResourceModel and then execute SQL.

Resources