- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2018
09:09 PM
04-08-2018
09:09 PM
Magento 1.9 Save manually added field to product page into Database.
I have added attribute Is Child Associated and make it Yes/No field in product create page in magento admin.
On the basis of above field I have displayed one dropdown on product page to select child for that product and save it in the db.
I have added below code in
app/design/frontent/rwd/default/template/catalog/product/view.php
<?php if ($_product->getAttributeText('is_child_associated') == "Yes"): if (Mage::getSingleton('customer/session')->isLoggedIn()) { $customer = Mage::getSingleton('customer/session')->getCustomer(); $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData(); } $ch = curl_init("http://localhost/store/child?email=".$customerData['email']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50); curl_setopt($ch, CURLOPT_TIMEOUT, 50); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response); if($result != NULL) { echo("<select name='childen' id='childen'>"); echo("<option value=''>Select child</option>"); foreach ($result as $key => $value) { echo '<option value="'.$value->ID.'">'.$value->ChildFirstName.' '.$value->ChildLastName.' (Grade '.$value->grades->Grade.')</option>'; } echo("</select><span class='error child-error' style='display:none;'>Please select your child.</span>"); } endif; ?>
Now I want to save above child field into db. How the operation would I perform exactly? Or there is another way to add field and save it into DB?
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018
09:36 PM
04-10-2018
09:36 PM
Re: Magento 1.9 Save manually added field to product page into Database.
Hi @Prash159,
I guess that second attribute will show different values based on the customer email. Right?