shebin512
shebin512
Reputation Top 1%
shebin512
7 Snippets  (134th place)
Published
2 Channels
Created
5 Channels
Following
Jan 6, 2017
Last Visit
Apr 5, 2014
Registered
9748 points  (10th place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Topic Creator
Junior Topic Hub
Junior Trend Maker
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Junior Famous Coder
Serious Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by shebin512

public by shebin512 created Jan 6, 2017  1889  2  5  0

Magento 1.x Update single Quote Item

Update a single quote Item in magento 1.x
<?php
// Update single quote Item/s qty/data.

// Step 1 : Load the quote object. This can be done in variety of ways depending on the location and usage.
$quoteId=1;
$itemId = 1234;// Items Id
$quote = Mage::getModel('sales/quote')->setStore($store)->load($quoteId);

// Step 2 : set the quote object qty manually

// prepare data.
  $params = array();
  $params['qty'] = 5;// similarly you can set any item attribute.
  $request = new Varien_Object($params);
  
// set Data.
  $quote->updateItem($itemId,$request);
                                    
;

public by shebin512 created Nov 29, 2016  6798  4  4  1

Format date in Arabic .

Format date in arabic without using the locale functions to avoid numeral conversion.
// Format date in Arabic
var date = new Date('2016-12-04');
var months = ["يناير", "فبراير", "مارس", "إبريل", "مايو", "يونيو",
              "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"];
var days =["اﻷحد","اﻷثنين","الثلاثاء","اﻷربعاء","الخميس","الجمعة","السبت"];
var delDateString = days[date.getDay()]+', '+date.getDate()+' '+months[date.getMonth()]+', '+date.getFullYear();

alert(delDateString); // Outputs اﻷحد, 4 ديسمبر, 2016
;

public by shebin512 created Oct 29, 2015  3787  1  7  1

Magento get current controller ,current module , current action and route name

Magento get current controller ,current module , current action and route name
<?php

/*
 *Magento get current controller ,current module , current action and route name
 */

//1 . controller name
Mage::app()->getRequest()->getControllerName();// will return controller name

//2. action name
Mage::app()->getRequest()->getActionName();//will return action name

//3. module name
Mage::app()->getRequest()->getModuleName();// will return module name

//4. routes name
Mage::app()->getRequest()->getRouteName();//will return routes name            
;

public by shebin512 created Oct 4, 2016  1523  1  5  0

Bash Script to clean magento 1.x Cache

Magento 1.x cache clean Bash script. 1. Save the code in "/path/of/the/file/.sh" 2. Give executable permission for the file "chmod a+x /path/of/the/file/.sh" 3. Run the script from your magento document root like $ /path/of/the/file/.sh
#!/bin/bash 
# author Shebin Sheikh

# function to remove the magento cache.
function mageCacheClear {

	local current_dir=$(pwd);
	#echo $current_dir
	#exit

	if [[ -f "$current_dir/app/Mage.php" ]]; then
		#echo "Inside Mage Doc root"
		rm -vrf var/{cache,full_page_cache}/ media/{js,css}/
	else
		echo -e "Not inside A magento 1.X's document root!"
		exit $?
	fi

}

mageCacheClear # call the function
;

public by shebin512 created Nov 27, 2015  2925  0  5  0

PHP Check current date greater than given/reference date.

PHP Check current date greater than given/reference date.
php
<?php

$date = date("m/d/Y");
$refDate = date("m/d/Y", strtotime("12/15/2012"));
if ($date > $refDate) {
  //logic
}
;