Skip to content

Instantly share code, notes, and snippets.

@devjosh12
devjosh12 / Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Settings
Created October 14, 2015 07:39
Show attribute sets according to role id's in admin while creating product
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@devjosh12
devjosh12 / Show Root Categories Alphabetically
Created September 27, 2015 07:25
Show Root Categories Alphabetically
<?php
$cats = Mage::getModel('catalog/category')->load(3)->getChildren();
$catIds = explode(',',$cats);
$categories = array();
foreach($catIds as $catId) {
$category = Mage::getModel('catalog/category')->load($catId);
$categories[$category->getName()] = $category->getId();
}
ksort($categories, SORT_STRING);
@devjosh12
devjosh12 / remove_other_shipping_methods
Last active August 29, 2015 14:27
Remove Other Shipping Methods on ONEPAGE If Free Shipping is Applicable.
GO TO : app/design/frontend/default/YOURTEMPLATE/template/checkout/onepage/shipping_method/available.phtml
Place Below Code:
<?php
if ( array_key_exists('freeshipping', $_shippingRateGroups )) {
unset($_shippingRateGroups["flatrate"]);
}
?>
<?php
//error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
<script>
jQuery(".attr_filter_input").keyup(function(){
this_input = jQuery(this);
this_input.parents("ol").find("li").each(function(){
this_li = jQuery(this);
if(this_li.index() != 0) {
this_input_value = this_input.val().toLowerCase();
this_li_label_text = this_li.find("label").text().toLowerCase();
if(this_li_label_text.indexOf(this_input_value) < 0)
this_li.hide();
@devjosh12
devjosh12 / index.php
Last active August 29, 2015 14:24
Autopopulate form by entering zipcode for INDIA only
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script >
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#postcode').blur(function(){ //.postcode class of zipcode text field
var s = jQuery(this).val();
jQuery.ajax({
type: 'POST',
url: "http://localhost/autopopulate/insertzip.php", //file which read zip code excel file
dataType: "json", //is used for return multiple values
data: { 's' : s },
@devjosh12
devjosh12 / gist:29da959bcbeea358e604
Created May 26, 2015 04:59
Add Pagination to custom product collection
<?php $_items = $this->getItems() ?>
<?php
$_convertedFinalPrice="";
if (($_items = $this->getItems()) && $_items->getSize()): ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php echo $this->getPagerHtml(); ?>
<?php $_collectionSize = $_items->count();
//echo $_collectionSize; ?>
<?php $_columnCount = 3; ?>
@devjosh12
devjosh12 / addcategory
Created March 21, 2015 06:37
add category
<?php include('config.php'); ?>
<style>
#search_category_id{ padding:3px; width:200px;}
#sub_category_id{ padding:3px; width:200px;}
</style>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<center><a href="view_categories.php">Show Categories</a>
<a href="addproduct.php">Add Products</a></center>
<form method="post" onsubmit="return(validate());" action="<?php $_PHP_SELF ?>" style="margin-top:20px;" name="myForm">
<table width="400" border="0" cellspacing="1" cellpadding="2" align="center">
@devjosh12
devjosh12 / checked
Created March 20, 2015 10:16
custom js checked
$(function () {
$('.btnGetAll').live("click",function () {
if ($('.chkNumber:checked').length) {
var chkId = '';
$('.chkNumber:checked').each(function () {
chkId += $(this).val() + ",";
});
chkId = chkId.slice(0, -1);
//alert(chkId);
$.ajax({
@devjosh12
devjosh12 / products
Created March 20, 2015 09:36
Products
<?php include('config.php'); ?>
<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="custom-script.js"></script>
<style>
#container {
border: 1px solid #000;
margin: 2% auto 0;
width: 100%;