Magento – Get Current Store Details (ID, Code, Name and Status)

How to Upgrade Magento community to 1.8

How to Upgrade Magento community to 1.8

// Gets the current store's details
$store = Mage::app()->getStore();
// Gets the current store's id
$storeId = Mage::app()->getStore()->getStoreId();
// Gets the current store's code
$storeCode = Mage::app()->getStore()->getCode();
// Gets the current website's id
$websiteId = Mage::app()->getStore()->getWebsiteId();
// Gets the current store's group id
$storeGroupId = Mage::app()->getStore()->getGroupId();
// Gets the current store's name
$storeName = Mage::app()->getStore()->getName();
// Gets the current store's sort order
$storeSortOrder = Mage::app()->getStore()->getSortOrder();
// Gets the current store's status
$storeIsActive = Mage::app()->getStore()->getIsActive();
// Gets the current store's locale
$storeLocaleCode = Mage::app()->getStore()->getLocaleCode();
// Gets the current store's home url
$storeHomeUrl = Mage::app()->getStore()->getHomeUrl();


Magento – Get Current Store Details (ID, Code, Name and Status)

What are the differences between ‘git pull’ and ‘git fetch’?


What are the differences between git pull and git fetch?


In the simplest terms, git pull does a git fetch followed by a git merge.

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/. This operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn’t recommend doing this).

A git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

Git documentation: git pull


When do you use git rebase instead of git merge?


When is it recommended to use git rebase vs. git merge?
Do I still need to merge after a successful rebase?

Short Version

  • Merge takes all the changes in one branch and merge them into another branch in one commit.
  • Rebase says I want the point at which I branched to move to a new starting point

So when do you use either one?


Let’s say you have created a branch for the purpose of developing a single feature. When you want to bring those changes back to master, you probably want merge (you don’t care about maintaining all of the interim commits).

A second scenario would be if you started doing some development and then another developer made an unrelated change. You probably want to pull and then rebase to base your changes from the current version from the repo.


How to use MySQL to search in PHP serialized fields

Well, first rule – you should not do this. But if there is good reason, consider using such query for searching in index-based arrays:

SELECT * FROM table WHERE your_field_here REGEXP '.*;s:[0-9]+:"your_value_here".*'

In case you have assoc array serialized you can use:

SELECT * FROM table WHERE your_field_here REGEXP '.*"array_key_here";s:[0-9]+:"your_value_here".*'

Of course it won’t be very fast but in small tables should be enough


Verify Item Purchases with the Envato API

This article focuses on how to simply and efficiently converse with Envato’s API in order to verify authors’ customers’ purchase codes in the author’s own applications. I talk through all the steps to setting up this function, covering how to create the unique API key required, using the PHP cURL function and interpreting the output.

    function verify_envato_purchase_code($code_to_verify) {
    // Your Username
    $username = 'USERNAME';
    // Set API Key  
    $api_key = 'API KEY';
    // Open cURL channel
    $ch = curl_init();
    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, "". $username ."/". $api_key ."/verify-purchase:". $code_to_verify .".json");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // Decode returned JSON
    $output = json_decode(curl_exec($ch), true);
    // Close Channel
    // Return output
    return $output;
$purchase_key = 'PURCHASE KEY TO CHECK';
$purchase_data = verify_envato_purchase_code( $purchase_key );
if( isset($purchase_data&#91;'verify-purchase'&#93;&#91;'buyer'&#93;) ) {
    echo '<strong>Valid License Key!</strong><br>Details;<ul>';
    echo '<li>Item ID: ' . $purchase_data['verify-purchase']['item_id'] . '</li>';
    echo '<li>Item Name: ' . $purchase_data['verify-purchase']['item_name'] . '</li>';
    echo '<li>Buyer: ' . $purchase_data['verify-purchase']['buyer'] . '</li>';
    echo '<li>License: ' . $purchase_data['verify-purchase']['licence'] . '</li>';
    echo '<li>Created At: ' . $purchase_data['verify-purchase']['created_at'] . '</li>';
    echo '</ul>'; 
else echo 'Invalid license key.';


Magento upgrading with Git


It’s rather easy but you have to ensure that your site is based on some master repo that can be merged down the stream with earlier versions (repo that has all Magento versions as tags or branches that can be merged to latest from first). So here’s two scenarios to follow

1. My site is not in git

  1. start by cloning from master repo that has all magento versions (at least to the version you are currently using)
  2. get your clone and checkout new branch with the version you are currently using
  3. copy over your current site to this version
  4. after that done “git status” will show you the diff with original version you started with and all the edits you have made to it
  5. its now smart to move all core edits to local codepool and revert any changes in core to original files, move any edts in default or base templates to your own template and revert changes in default or base template files. Same goes with all the files that look modified against the original version. This gives you “all my changes are separate from original code and they will not conflict my upgrades”, it’s wise to commit this state
  6. If all things are separated from original files then it’s time to upgrade. Turn on default theme, disable all local and community extensions , merge the new version with your current branch. Visit the site to perform the upgrade
  7. Now your site is upgraded and you can turn on your theme and custom extensions one by one to see what is compatible and what not. Debug and solve one by one

My site is already in git

  1. if it is based on repo that has all versions you are in good condition (skip 2)
  2. if it’s not then you can add some repo that has it all as your remote and start with merging your current version and separating changes from original like described in first scenario
  3. make a new branch of your current site used
  4. merge with new version
  5. disable all local, community extensions, turn on default theme, and upgrade
  6. enable theme, extensions one by one and debug where conflicts happen

It’s common to have a git setup like follows:

    • branch: yoursite_dev
    • branch: yoursite_stage
    • branch: yoursite_live

You always develop on your_dev branch andif changes are ready for evaluation you merge _stage with _dev and if changes are approved you merge the state to _live either from _dev or from _stage.

commands based on theoretical endpoints

git clone git:// yourprojectdir
cd yourprojectdir
git fetch --tags
git tag
git checkout -b yoursite_dev magento-
git checkout -b yoursite_stage yoursite_dev
git checkout -b yoursite_live yoursite_dev
git checkout yoursite_dev
git branch
//copy in your site
//separate changes or originals
//add any file/dir with local importance to .gitignore
//turn of your default theme, disable all local/community extensions and overrides
//assuming you are on dev branch commit your clean state
git merge magento-
//visit the site to execute the upgrade
//enable your theme , extensions , debug

this gives you a starting point for scenario 1 and after that you could just copy in your site and start separating changes and making order in your current site and themes.


PayPal Offerings Worldwide


Use PayPal to send and receive money worldwide. With over 230 million accounts worldwide and growing, we help you securely, easily and quickly pay and get paid locally and across borders.

CakePHP How to change the X-Mailer

Basically, on your CakeEmail object:

$CakeEmail = new CakeEmail();
$CakeEmail->addHeaders(array('X-Mailer' => 'My custom X-Mailer'));

If set manually Cake will not add his default value ‘CakePHP Email’.


Verify hex color string

Verify hex color string

Verify hex color string

This php script checks is the string $color is a hex color or not. The second IF statement will add the pound symbol at the beginning if it is missing from the hex color value.


//Check for a hex color string '#c1c2b4'
if(preg_match('/^#&#91;a-f0-9&#93;{6}$/i', $color)) //hex color is valid
      //Verified hex color

//Check for a hex color string without hash 'c1c2b4'
else if(preg_match('/^&#91;a-f0-9&#93;{6}$/i', $color)) //hex color is valid
      $fix_color = '#' . $color;



Page 1 of 241234567»

Pin It on Pinterest