Archive for the ‘Magento’ Category

How to Import Products in Magento Tutorial

Friday, September 21st, 2012

Here at Web Design GM we have developed many e-commerce websites for clients who have vast quantities of products they want to import on their new Magento website. The trouble with the native Magento import and export feature is that if you are importing over a 500 products then you may have issues with the following:

  • Edit the .htaccess file and increase the PHP memory.
  • Products may take a long time to upload.
  • Reindexing can take forever if you have loads of products in Magento.
  • If the format of the of a particular product in the .CSV is incorrect then none of the products will be imported until the format of all of the products in 100% correct.
  • You need to map the columns exactly how Magento likes to imports products there is no flexibility and it is very rigid and frustrating that they have not addressed this issue.
  • You can not import images so if you have 1000′s of products then you would have to manually upload images to all of the products.
  • You can not create categories on the fly or attributes so you will have to either create them programatically or manually create them which can take forever if you have many categories or attributes to create.

Fortunately for everyone we have a something which can help with all of the above and some. Sebastien Bracquemont aka Dweeves has developed a software which has really changed the way we import or export products. is a software which is extracted to the root of your Magento folder and it accesses your database and imports products at “lighting speeds”. Some of Magmi’s feature are the following:

  • Direct SQL Magento product import.
  • Advance features, flexible CSV formats, value replacer and much more.
  • Configurable products are allowed to be imported.
  • Tier pricing can be imported.
  • Create categories on the fly.
  • There is more features listed on their website.

Layered Navigation on Home Page or Any CMS Page Magento

Tuesday, August 14th, 2012

We recently had a client approach us and request that they want a navigation on the sidebar of every page of their new Magento shop. At first we thought this would be very easy to add and take a few hours to download a plugin and have the categories push to every page. We soon established they wanted the layered navigation to be present on the homepage and then filter through all of the attributes.

Unfortunately Magento does not allow this to happen and there are many plugins out there that charge a fortune for something which is relatively easily to do. We are going show you how to get the layered navigation to any of your CMS pages and how to give it a cool and sexy accordion effect using jQuery. There are a lot of forums which have this type of post but none of them work as well as this nor do they have an accordion effect too. This has been tested on Magento 1.5

The first step is to navigate yourself to your CMS pages in the backend and update the XML file for your home page. This can be done by going to:

CMS > Manage Pages > Homepage > Layout Update XML and in here please place the code below:

<reference name="left">
    <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/homeview.phtml"/>

Second step is going navigate yourself through some code. Please go to /app/code/local/mage/catalog/model/layer.php and do not rewrite the original file, make a copy of it in the local folder.

Find this code:

public function getCurrentCategory()
  $category = $this->getData('current_category');
  if (is_null($category)) {
      if ($category = Mage::registry('current_category')) {
          $this->setData('current_category', $category);
      else {
          $category = Mage::getModel('catalog/category')->load($this->getCurrentStore()->getRootCategoryId());
          $this->setData('current_category', $category);
  return $category;

Replace the above code with this code below:

public function getCurrentCategory()
  $category = $this->getData('current_category');
  if (is_null($category)) {
      if ($category = Mage::registry('current_category')) {
          $this->setData('current_category', $category);
      else {
          $category = false;
          $this->setData('current_category', $category);

  //added to make this work for front page:
  if(is_null($category) || $category == false) {      
      $home_category = Mage::getModel('catalog/category')->load(40); //number must correspond to 'all products page' category
      $this->setData('current_category', $home_category);
      $category = $this->getData('current_category');
      //return $category;
  //end addition

  return $category;

This is the only part where you will need to edit the core files but like suggested please place the code in the local folder rather then hacking the core files.

Next step is to create a file called homeview.phtml in /template/catalog/layer/ with the following code:

<?php if($this->canShowBlock()): ?>
<div class="block adv-search-nav">
    <div class="block-content">
        <?php echo $this->getStateHtml() ?>
        <?php if($this->canShowOptions()): ?>
 <?php /*?><p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p><?php */?>
            <dl id="narrow-by-list">
                <?php $_filters = $this->getFilters() ?>
                <?php foreach ($_filters as $_filter): ?>
                <?php if($_filter->getItemsCount()): ?>
					<?php if($this->__($_filter->getName() == "Category")): ?>
                    	<dt><a href="JavaScript:void(0);">Type</a></dt>
						$category_model = Mage::getModel('catalog/category');
						$_category = $category_model->load(9); 
						$all_child_categories = $category_model->getResource()->getAllChildren($_category);
									foreach($all_child_categories as $id):
										$childCategory = $category_model->load($id);
										if($childCategory->getName() == "shop" || ($childCategory->getEntityId() == 10 || $childCategory->getEntityId() == 11 || $childCategory->getEntityId() == 12 || $childCategory->getEntityId() == 13 || $childCategory->getEntityId() == 14 
										|| $childCategory->getEntityId() == 16 || $childCategory->getEntityId() == 17 || $childCategory->getEntityId() == 18 || $childCategory->getEntityId() == 19) ):
											echo "<li>";
											echo '<a href="/shop.php?cat='.$childCategory->getEntityId().'" id='.$childCategory->getEntityId().'>'.$childCategory->getName().' <span class="product-items">('.Mage::getModel("catalog/category")->load($id)->getProductCount().')</span></a>';
											echo "</li>";
                    <?php else: ?>
                        <dt><a href="JavaScript:void(0);"><?php echo $_filter->getName() ?></a></dt>
                        <dd><?php echo str_replace(array('?','/?'),array('shop.php?','/shop.php?'),$_filter->getHtml()) ?></dd>
                    <?php endif; ?>
                <?php endif; ?>
                <?php endforeach; ?>
            <script type="text/javascript">decorateDataList('narrow-by-list')</script>
        <?php endif; ?>
<?php endif; ?>

<script type="text/javascript">
		$j("dl#narrow-by-list> dd:visible").hide();
		$j("dl#narrow-by-list> dt a").addClass('test1');
		$j("dl#narrow-by-list> dt a").click(function(){
			$j("dl#narrow-by-list> dt a").addClass('test1').removeClass('test2');
			$j("dl#narrow-by-list> dd:visible").slideUp("fast");
		$j("dl#narrow-by-list> dt a").addClass('test1').removeClass('test2');

Replace the category ids etc to match yours. This navigation should push through all of your attributes and all of you categories as well. The rest is up to you how you style it, if you have any question please comment on our blog thanks.

Great new features of Magento 1.7

Friday, July 27th, 2012

At Morgan Creare we have long been awaiting the launch of the latest Magento Community Edition release, Magento 1.7.

The Magento team promised useful feature upgrades as well as a round of updates and of course reliability and performance improvements on the previous 1.6 version.

Here are three new features to watch out for:

EU Cookie Restriction

Magento have provided an in-built Cookie notification feature to ensure users keep inline with the recent EU Privacy and Electronic Communications Directive. When this handy little feature is activated a message appears at the top of the screen informing users that about the companies cookie policy and asks for the user to either accept or decline the cookie.

To access this go into System > Configuration > Web > Session Cookie Management > Cookie Restriction Mode

Change this to yes and the cookie message will appear.


There is now an CAPTCHA option that can be enabled in order to stop automated software from tying to access not only the admin area but the customer login area too.

To enable CAPTCHA for admin access navigate to System > Configuration > Advanced > Admin > CAPTCHA

Change the drop down box for ‘Enable CAPTCHA in Admin’ to yes.

To enable CAPTCHA for the front end navigate to System > Configuration > Customers > Customer Configuration > CAPTCHA

Change the drop down box for ‘Enable CAPTCHA on Frontend’ to yes.

Scheduled Backup

There is now a really simple and effective way of ensuring that your Magento store is backed up. With this new function there is no excuse not to make regular backups.

You can select the frequency of your backups, this can be set to daily, weekly or monthly intervals. You now also have the option to put the store into maintenance mode whilst the backup is taking place, ensuring that your potential customers are aware of why your store is temporarily unavailable.

To access this feature go to System > Configuration > Advanced > System > Scheduled Backup Settings

There are many more features that we are coming across on a daily basis, we will share these with you sometime in the near future.

Adding Free Sample or Tester Products in Your Magento Shop

Tuesday, July 24th, 2012

Today here at Web Design GM are going to discuss how to add sample or tester products to your Magento shops. There are many old tutorials which are out of date and simply do not work. We have tested this solution with Magento version 1.5 and 1.7. Free sample products or free tester products are ideal for e-commerce websites that require giving their customers for example tester materials or sample perfumes for instance.

You can restrict the amount of free sample products you want give out to your clients because you do not want people to have let’s just say a 100 free sample products. instead this tutorial will restrict the sample product to 5 but you can edit the code you change it to whatever you feel is the right amount.

1. Firstly you will need to create a file called getSample.php in the root of your Magento installation folder and populate it with the following code.


ini_set('display_errors', 1);


require_once 'app/Mage.php';

Mage::getSingleton("core/session", array("name" => "frontend"));
// Store users session
$session = Mage::getSingleton("customer/session");
//Store cart items
$totalNumOfCartItem = Mage::getModel('checkout/cart')->getItemsQty();

//Store cart items
$theitems = Mage::getModel('checkout/cart')->getItems();

$thecount = 0;

foreach($theitems as $ti){

	$thename = $ti['name'];

	$test = strpos($thename,'Free Sample');

	if($test !== false){
	$thecount = $thecount+1;


$name = $_POST['name'];

$id = $_POST['id'];
if(isset($_POST['simpleid']) && !empty($_POST['simpleid'])){
$simpleid = $_POST['simpleid'];
$name = $_GET['name'];
if(isset($_GET['simpleid']) && !empty($_GET['simpleid'])){
$simpleid = $_GET['simpleid'];
$id = $_GET['id'];

// retrict shopping cart to only allow 5 samples 
if ($totalNumOfCartItem <= 4)
$theproduct = Mage::getModel('catalog/product')->load($id);

$thesimple = Mage::getModel('catalog/product')->load($simpleid);

if($thecount < 2){

// instatiate Product
$product = Mage::getModel('catalog/product'); 
} else {
$product->setName("Sample of ".$name);
// $product->setDescription("Sample of ".$name);
$product->setShortDescription($name." - Sample");

$product->setImageUrl($theproduct->getImageUrl()); // set the images from the original product
$product->setMediaGallery (array('images'=>array (), 'values'=>array ()));
$product->addImageToMediaGallery($_SERVER['DOCUMENT_ROOT']."/media/catalog/product".$theproduct->getSmallImage(), array('image','small_image','thumbnail'), false, false); 
$product->setAttributeSetId(9); // need to look this up
$product->setCategoryIds("15"); // need to look these up
$product->setTaxClassId(2); // taxable goods
$product->setVisibility(1); // catalog, search
$product->setStatus(1); // enabled 
// assign product to the default website

// get product's general info such price, status, description

$stockData = $product->getStockData();

// update stock data using new data
$stockData['qty'] = 1;
$stockData['is_in_stock'] = 1;
$stockData['manage_stock'] = 1;
$stockData['max_sale_qty'] = 5;

// then set product's stock data to update

// call save() method to save your product with updated data

header("Location: /checkout/cart/add/product/".$product->getId()."/"); 

Mage::getSingleton('checkout/session')->addError("You are only allowed a maximum of 5 sample products");

header("Location: /checkout/cart");

The above code is simply the function which will create sample products for you on the fly. Also not that in this example we have assigned each sample product with a ridiculous weight because the client offered the sample product and the shipping of the sample products for free meaning we had to create a table rate for the shipping method which did not interfere with the other shipping logic so that anything that exceeds 21212121 will have free shipping.

2. Next you will need to create a button where you want people to add a free sample product in the shopping basket. I have placed my sample button in the list.phtml and placed the button in both my list view and grid view.

<form action="/getSample.php" method="post">
      <input type="hidden" name="id" value="<?php echo $_product->getId() ?>" />
      <input type="hidden" name="name" value="<?php echo $this->htmlEscape($_product->getName()) ?>" />
      <input type="image" name="getsample" alt="Get Sample for <?php echo $this->htmlEscape($_product->getName()) ?>" src="<?php echo $this->getSkinUrl('images/your_theme_name/sample-btn.jpg') ?>" />

The above will execute the getSample.php and add a sample product to your shopping basket whilst still allowing you to purchase other products from the Magento shop.

Magento: PHTML Files In Dreamweaver

Tuesday, August 3rd, 2010

By default, Dreamweaver cannot display PHTML files correctly. You will notice that if you open a PHTML file it will be in black and white, making it harder to edit. So if you use Dreamweaver to develop your websites and would like to be able to view Magento’s PHTML files then you can follow some simple steps to allow Dreamweaver to display the files correctly for easier editing. (more…)

Contact Us Today...

If you have any questions about our services or want to arrange a free no obligation consultation contact us today or call 02920 290 080 for Cardiff and 01179 000 482 for Bristol.

Bit Torrent Study Discovers Most File Sharers Are Now Monitored

Ever heard of torrents or used Bit Torrent to download movies, music or shared files over the internet? Researchers have discovered that anyone who does use Bit Torrent to download files over the World Wide Web will most probably be monitored. Studies were carried out by Birmingham University and they have discovered that if someone [...]
» more

Cardiff: 02920 290 080 Bristol: 01179 000 482