Sunday, August 30, 2015

Custom Step Checkout Page

public function saveExcellenceAction(){ if ($this->_expireAjax()) { return; } if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('excellence', array()); // my custom code start $custom_price = $data['like']; $quote = Mage::getSingleton('checkout/session')->getQuote(); $product1 = Mage::getModel('catalog/product')->loadByAttribute('sku',$bundlePackageSku); $bundler_Price = $custom_price; foreach($quote->getAllVisibleItems() as $quote_item1) { $productPrice = $quote_item1->getProduct()->getPrice(); //print_r(get_class_methods($quote_item1)); $quote_item1->setPrice($bundler_Price + $productPrice); $quote_item1->setCustomPrice($bundler_Price + $productPrice); $quote_item1->setOriginalCustomPrice($bundler_Price + $productPrice); $quote_item1->setRowTotal($bundler_Price + $productPrice); $quote_item1->save(); } // my custom code end $result = $this->getOnepage()->saveExcellence($data); if (!isset($result['error'])) { $result['goto_section'] = 'billing'; } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); } }

http://stackoverflow.com/questions/1085801/get-selected-value-in-dropdown-list-using-javascript

Tuesday, August 4, 2015

Custom tab add in magento admin system configuration

Custom tab in magento admin system configuration :
How to create custom tab or menu from magento admin system configuration section. Easiest way to create, just need to follow below steps
We just want to create below two files, in your required place. Here my module is called ModuleName.

app\code\local\NameSpace\ModuleName\etc\system.xml
app\code\local\NameSpace\ModuleName\etc\adminhtml.xml


system.xml:


<?xml version="1.0"?>
<config>
    <tabs>
        <my_custom_tab translate="label" module="admincontact">
            <label>My Custom Tab</label>
            <sort_order>0</sort_order>
        </my_custom_tab>
    </tabs>
    <sections>
        <my_custom_section  translate="label" module="admincontact">                   
            <label>My Custom Section</label>
            <tab>my_custom_tab</tab>
            <frontend_type>text</frontend_type>
            <sort_order>0</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>           
            <groups>
                <my_custom_group translate="label">
                    <label>My Custom Group</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>0</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>

<inchoo_select translate="label">
                            <label>Your Module Has Been Display </label>
                            <comment>Source model provider Magento's default Yes/No values</comment>
                            <frontend_type>select</frontend_type>
                            <sort_order>0</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        </inchoo_select>



                        <my_custom_field translate="label">
                            <label>My Custom Field</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>90</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Any comment I can set here</comment>
                            <tooltip>Field ToolTip</tooltip>
                        </my_custom_field>





 <textarea translate="label comment">
                            <label>Textarea</label>
                            <comment>Textarea with store view scope.</comment>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </textarea>


<file translate="label comment">
                            <label>File</label>
                            <comment><![CDATA[File saved in <strong><span style="color: red;">var/uploads</span></strong> folder.]]></comment>
                            <frontend_type>file</frontend_type>
                            <backend_model>adminhtml/system_config_backend_file</backend_model>
                            <upload_dir>var/uploads</upload_dir>
                            <sort_order>50</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </file>


<text_field translate="label comment">
                            <label>Please Input Your Text</label>
                            <comment>Text field with store view scope.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </text_field>


                    </fields>


                </my_custom_group>
            </groups>
        </my_custom_section>
    </sections>

</config>


adminhtml.xml:

<?xml version="1.0"?>
    <config>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <my_custom_section translate="title" module="admincontact">
                                            <title>My Custom Section Section</title>
                                            <sort_order>0</sort_order>
                                        </my_custom_section>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>

    </config>


To retrieve data saved in your configuration, you should use something like this:

Example :  $configValue =Mage::getStoreConfig('sectionName/groupName/fieldName');


echo $configValue = Mage::getStoreConfig('my_custom_section/my_custom_group/text_field'); 

Create Custom Contact us form in Magento

Step 1:app/design/frontend/default/default/template/admincontact/simple_contact.phtml



     <form action="<?php echo Mage::getBaseUrl().'admincontact/index/save' ?>" id="contactForm" method="post"         name="contact_form">
            <div class="fieldset">
                <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
                <ul class="form-list">
                    <li class="fields">
                        <div class="field">
                            <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
                            <div class="input-box">
                                <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
                            </div>
                        </div>
                        <div class="field">
                            <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
                            <div class="input-box">
                        <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
                    </div>
                </div>
            </li>
            <li>
                <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
                <div class="input-box">
                    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="tel" />
   
                </div>
            </li>
            <li>
                <label for="subject"><?php echo Mage::helper('contacts')->__('Subject') ?> <span class="required">*</span></label>
                <div class="input-box"><input name="subject" id="subject" title="<?php echo Mage::helper('contacts')->__('Subject') ?>" value="" class="required-entry input-text" type="text"/>
                </div>
            </li>
            <li class="wide">
                <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
                <div class="input-box">
                    <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
                </div>
            </li>
        </ul>
    </div>
    <div class="buttons-set">
        <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
        <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
        <button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
    </div>
</form>
<script type="text/javascript">
    //<![CDATA[
    var contactForm = new VarienForm('contactForm', true);
    //]]>
</script>


Step 2 :- app/code/local/Inchoo/admincontact/controllers/IndexController.php

public function saveAction(){

if ( $data = $this->getRequest()->getPost() ) {

 //$model = Mage::getModel('admincontact/admincontact');
   $model = Mage::getSingleton('admincontact/admincontact');
            $model->setData($data);
           $model->save();
  $message = $this->__('Data has been saved');
Mage::getSingleton('core/session')->addSuccess($message);


}
else{

  $message = $this->__('Data has been Not saved');
Mage::getSingleton('core/session')->addSuccess($message);
}



Step 3:  Database in data Save Successfully.