Skip to main content

Posts

Add Dynamic data on magento admin form

<?php class Ankur_Banners_Block_Adminhtml_Banners_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form { protected function _prepareForm() { $form = new Varien_Data_Form(); $this->setForm($form); $fieldset = $form->addFieldset("banners_form", array("legend"=>Mage::helper("banners")->__("Item information"))); $fieldset->addField('lable', 'hidden', array( 'label'     => Mage::helper('megamenu')->__('Add Images'), 'name' => 'label', 'after_element_html' => '<div id="add_more"></div><button id="add" class="add_field_button"  type="button" >Add Images</button>' )); if (Mage::getSingleton("adminhtml/session")->getBannersData()) { $form->setValues(Mage::getSingleton("adm

Get Attribute Value , type by attribute id

 $attribute = Mage::getModel('eav/entity_attribute')->load($attr); $type=$attribute->getFrontendInput(); $attrLabel=$attribute->getFrontendLabel(); $attrName=$attribute->getAttributeCode(); //echo $attribute->getData($attrName);die;  if($type=='multiselect'){ $html.='<div class="field"><label for='.$attrName.'"  class="required">'.$attrLabel.': </label><div class="input-box"><select multiple id="'.$attrName.'"  name="product['.$attrName.'][]" >'; //$values=$attribute->getSource()->getAllOptions(true, true); $values=$attribute->getAttributeText($attrName); $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product',$attrName); $collection =Mage::getResourceModel('eav/entity_attribute_option_collection

Magento Update product status programmatically

public function updateproductstausAction(){ $productid=$this->getRequest()->getParam("product_id"); if($this->getRequest()->getParam("val")==0){ // product id which you want to change status; $storeid=0 ;// your store id 0 is for default store id Mage::getModel('catalog/product_status')->updateProductStatus($productid, $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED); } elseif($this->getRequest()->getParam("val") =='1'){ $storeid=0 ;// your store id 0 is for default store id Mage::getModel('catalog/product_status')->updateProductStatus($productid, $storeid, Mage_Catalog_Model_Product_Status::STATUS_ENABLED); } }

Step by Step validating jquery-steps form with bootstrap validator

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <link rel="stylesheet" href="http://formvalidation.io/vendor/formvalidation/css/formValidation.min.css" /> <link rel="stylesheet" href="http://formvalidation.io/vendor/jquery.steps/css/jquery.steps.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="http://formvalidation.io/vendor/formvalidation/js/formValidation.min.js"></script> <script src="http://formvalidation.io/vendor/formvalidation/js/framework/bootstrap.min.js"></script> <s

Call Controller by Ajax in Magento Admin 1.9

<form action=" id="mass_forms"> <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /> <select id="mainStatus" onChange="getSubStatus()"> <option value=''>Select Status</option> <?php foreach($item_Status as $itemstatus){?> <option value='<?php echo $itemstatus['id'] ?>'><?php echo $itemstatus['value'] ?></option> <?php } ?> </select> </form> //////////////////////////////////////////////////////////////////////////////// Script: <script> function getSubStatus(){ var posdata = jQuery("#mass_forms").serializeArray(); var url =  "<?php echo $this->getUrl('marketplaceadmin/adminhtml_orderview/getsubstaus');?>"; jQuery.ajax({ type: "POST", url: url, datatype: "text

indian Pin code Validation

<html> <head> <title>Sample Code</title> <script type="text/javascript"> function CheckIndianZipCode(MyZipCode) {        var CheckZipCode = /(^\d{6}$)/;        if(CheckZipCode.test(MyZipCode))        {              document.getElementById('p1').innerHTML ="valid";        }        else        {              document.getElementById('p1').innerHTML ="Your Entered Zip Code Is Not Valid.";        } } </script> </head>       Enter String : <input type="text" name="txtOriginal" onKeyup="CheckIndianZipCode(this.value);" /><br> <p id="p1">Hello Ankur</p>