Skip to main content

Posts

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>

Get all product attributes for a magento object using SQL

Sometimes you may want to quickly compare all of the attributes that object (category / product) has in magento. The EAV structure of the database makes this difficult to do this simply, so this is a query that will do it for you SELECT * FROM ( SELECT ce . sku , ea . attribute_id , ea . attribute_code , CASE ea . backend_type WHEN 'varchar' THEN ce_varchar . value WHEN 'int' THEN ce_int . value WHEN 'text' THEN ce_text . value WHEN 'decimal' THEN ce_decimal . value WHEN 'datetime' THEN ce_datetime . value ELSE ea . backend_type END AS value , ea . is_required AS required FROM catalog_product_entity AS ce LEFT JOIN eav_attribute AS ea ON ce . entity_type_id = ea . entity_type_id LEFT JOIN catalog_product_entity_varchar AS ce_varchar ON ce