Skip to main content

Store in DB using AJAX - Magento

JS
--------------
var designInitialArray = {};
designInitialArray['template_id'] = document.getElementById('customer_template_id').value;
designInitialArray['design_code'] = design_code;
designInitialArray['product_id'] = product_id;
designInitialArray['customer_id'] = customer_id;
var designInitial_jsonString = JSON.stringify(designInitialArray);

$.ajax({
    type: "POST",
    url: "productdesigner/tool/customer_design_initialize/",
    data: {data: designInitial_jsonString},
    success: function (oup) {
        alert(oup);
    }
});


CONTROLLER ACTION
-------------------
Mage::getModel('productdesigner/customerdesign')->customer_design_initialize($_POST['data']);


MODEL
-------------

$items = array();
$oldarray = json_decode($data);
foreach ($oldarray as $key => $item) {
    $items[$key] = $item;
}


$hot_spot = Mage::getModel('productdesigner/itemhotspot');
$hot_spot->setData($items);

Popular posts from this blog

The old company comeup with new brand MAXBEN - Logo meaning

I am so happy to design this logo for my friend Suresh Mahalingam to boost his paint business to the next level. The first step in his process is logo design. He had a clear idea about his business, processes, pricing and target audience. I just collect all those information from him and created the logo with some appropriate meanings. Check out the logo here