Skip to main content

Posts

Showing posts from 2017

How to create Guest Wishlist For Magento

Add to wishlist without customer login Add three tables CREATE TABLE `wishlist` ( `wishlist_id` INT(11) NOT NULL AUTO_INCREMENT, `customer_id` INT(11) NULL DEFAULT NULL, `shared` INT(11) NULL DEFAULT NULL, `sharing_code` VARCHAR(50) NULL DEFAULT NULL, `updated_at` TIMESTAMP NULL DEFAULT NULL, `cookie` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`wishlist_id`) ) COLLATE='latin1_swedish_ci' ENGINE=InnoDB AUTO_INCREMENT=0 ; CREATE TABLE `wishlist_item` ( `wishlist_item_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Wishlist item ID', `wishlist_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Wishlist ID', `product_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Product ID', `store_id` SMALLINT(5) UNSIGNED NULL DEFAULT NULL COMMENT 'Store ID', `added_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Add date and time', `description` TEXT NULL COMMENT '

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>

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