Store Restriction Pro Version 0.3.0 has been released

October 30, 2011  |  No Comments  |  by Raj (MagePsycho)  |  Magento

This is an announcement that Store Restriction Pro has been updated with lots of new exciting features which customer were waiting for at the very same price.


– Code Refinement
– Addition of News features:
– Option to allow Restricted store wise allowed CMS
– Option to allow Restricted store wise Module(Contact Us)
– Implemented the locale for translation

Upcoming Features:

– Option to allow Restricted store wise allowed Categories
– Option to allow Restricted store wise allowed Products
– Option for customer activation during registration
– Option for choosing predefined Customer Group during registration/new account creation.
– & many more.

Let me know if you have any idea regarding new features to be included in Store Restriction Pro.
Your suggestions are always welcome.

Thanks to our beloved customers for making this product a great success.
It’s just your love that made me to update this extension with lots of new exciting features.

Thanks once again.

How to import product images from external url in magento

October 27, 2011  |  23 Comments  |  by Raj (MagePsycho)  |  Magento, PHP


Generally, we import the product images by copying all the images to /media/import folder, adding image path relative to /media/import in csv corresponding to the product skus and running the import profile.

Sometimes you may need to import images from external url and this is the case when you are using third party web services or migrating non magento cart to magento.


Suppose say we have a csv with an extra field: external_image_url for product import.

1> Copy app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php to the local code pool so that new path looks like:

2> Open the Product.php from local code pool and search for the following code within saveRow() function:

foreach ($imageData as $file => $fields) {
	try {
		$product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import' . trim($file), $fields);
	catch (Exception $e) {}

Add the following code just below it:

$image_url  = $importData['external_image_url']; //get external image url from csv
$image_type = substr(strrchr($image_url,"."),1); //find the image extension
$filename   = md5($image_url . $importData['sku']).'.'.$image_type; //give a new name, you can modify as per your requirement
$filepath   = Mage::getBaseDir('media') . DS . 'import'. DS . $filename; //path for temp storage folder: ./media/import/
file_put_contents($filepath, file_get_contents(trim($image_url))); //store the image from external url to the temp storage folder
$mediaAttribute = array (
 * Add image to media gallery
 * @param string        $file              file path of image in file system
 * @param string|array  $mediaAttribute    code of attribute with type 'media_image',
 *                                         leave blank if image should be only in gallery
 * @param boolean       $move              if true, it will move source file
 * @param boolean       $exclude           mark image as disabled in product page view
$product->addImageToMediaGallery($filepath, $mediaAttribute, false, false);

3> That’s all. Now you can proceed with normal dataflow import profile.

From above code it is clear that we have used the php functions: file_get_contents() & file_put_conents() for the purpose.
Be sure to check if the fopen wrappers have been enabled or not in order to use url as parameter for file_get_contents(). Refer the configuration directive: allow-url-fopen for more info.

Let me know your feedback regarding this article.

Thanks for reading.

EDIT: FYI, this code was tested in Magento 1.5.x version.

Usage of <can_be_empty> tag for system configuration multi-select field

October 22, 2011  |  2 Comments  |  by Raj (MagePsycho)  |  Latest, Magento

Suppose say you have following multi-select field in System > Configuration:

Multi-Select Field - Customer Groups

Multi-Select Field - Customer Groups

which is defined by following xml code (partial):
File: app/code/local/MagePsycho/Demomodule/etc/system.xml

<allowed_groups translate="label">
	<label>Main Website / Main Store / English</label>

When you try to de-select the only one selected option from multi-select field(refer the above snap) and save the config, you will notice that option is not de-selected. In short, config cannot save multi-select field with empty selection. You may feel that it’s a bug in magento but unfortunately it’s not a bug, it’s a feature :). If you want to select none of the options from multi-select field, you need to use the tag: <can_be_empty> with value = 1 as:

<allowed_groups translate="label">
	<label>Main Website / Main Store / English</label>
	<can_be_empty>1</can_be_empty><!-- Note this line -->

So from above it is clear that usage of <can_be_empty> with value 1 allows the empty selection for multi-select field.
The logic behind this goes as:
if <can_be_empty> is true, the system renders a hidden field on the System Configuration page
File: lib/Varien/Data/Form/Element/Multiselect.php

if ($this->getCanBeEmpty()) {
    $html .= '<input type="hidden" name="' . parent::getName() . '" value="" />';

[Ref: In Depth Magento System Configuration]

Hope this demystyfies the usage of <can_be_empty> for system configuration multi-select field.

Thanks for reading.

Integrating Zopim Live Chat in your Magento Store

October 22, 2011  |  12 Comments  |  by Raj (MagePsycho)  |  Javascript, Latest, Magento


If you look at the right-bottom of this page, you will notice a nice looking chat widget. Yes that’s the Zopim Live Chat.

If you want to interact with your visitors, give support to them, know the statistics of the visits, get offline messages etc. then Zopim Live Chat seems to be very promising choice.

Integration of Zopim Live Chat

If you want to add Zopim Live Chat to your Magento Store, you don’t need to use any third party modules as it is so simple & straight forward to use.

Integration Steps:

  1. 1. Sign up with Zopim

    Visit Zopim site to sign up/create a account. Once you complete the sign up form then you will get a confirmation link in your mail for verification. Once confirmed your account is ready to use the Zopim Live Chat widget.
    Related Snaps:

    Sign Up: Step 1

    Sign Up: Step 1

    Sign Up: Step 2

    Sign Up: Step 2

  2. 2. Grap the Widget Code

    Login to the Zopim Dashboard page with the credentials used during sign up. After login, click on the Settings tab on the top right then you can see the following screen:

    Zopim Dashboard Settings

    Zopim Dashboard Settings

    When you are in Settings section,then you can see two tabs on the left: ‘Embed widget on my site‘ & ‘Customize widget‘.

    Embed widget on my site‘ -> When you click on this tab you will see the script ready for copy-paste in Magento.
    Customize widget‘ -> Click on this tab if you want to customize the look and feel, default text, position etc of your chat widget.

  3. 3. Insert the Widget Code in Magento

    After getting the Widget code(Zopim Dashboard > Settings > Embed widget on my site) from Zopim Site, login to the Magento and go to:
    System > Configuration > General > Design > Footer > Miscellaneous HTML > Paste the widget code here..

    Magento Configuration Settings for Zopim Live Chat

    Magento Configuration Settings for Zopim Live Chat

  4. 4. You’re done 🙂

    Refresh the cache and load the frontend page, you will see the sexy chat widget ready for interaction.

    Zopim Live Chat Demo

    Zopim Live Chat Demo

    Isn’t it’s so simple to integrate?

Note: A very simplistic Magento Extension has been developed for Zopim Live Chat which is very simple to use and upgrade proof. You can find the extension of Zopim Live Chat » here «.

Thanks for reading guys.

Happy Chatting!!