1. Home
  2. Prices
  3. Guided Tour
  4. New Shop
  5. Shop Review
  6. Ecommerce Marketing
  7. Ecommerce TV
  8. Magento Developers
  9. Portfolio
  10. Blog
  11. Contact

Author Profile

Author Archive

Subcategories Within Categories

Posted on: 19th Jul 2010 By: Adam Moss 1 Comment

I did a tutorial ages ago about how to import the subcategories of a product within another category via a static block. The details were shady and the logic was sketchy in those days, now I can look upon it with a sense of absolute knowledge and appreciation. Before digressing uncontrollably, let me get straight to the point.

Subcategories

1. Create a page called subcategory.phtml in the following folder: app/design/frontend/base/default/template/catalog/navigation/ and use the following code:

<?php $_categories = $this->getCurrentChildCategories(); ?>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
<?php endif; ?>
<?php endforeach; ?>

This is the code represented as simply as possible, it will produce a list of links that are contained within that category, you’re free to style this as you wish.

2. Create a static block called Subcategories and enter the following code into the content:

{{block type="catalog/navigation"  template="catalog/navigation/subcategory.phtml"}}

3. Now go to the category which you’d like to use to show the subcategories and ensure that it is not set as an anchor. In the Display options tab, set it to show as ‘Static Block Only’ and choose the block ‘Subcategories’.

Add Subcategory Image

If you want to take it one step further and show the image of the subcategory to make it more visual, you need to make a simple hack and add a bit of code to the original code in subcategory.phtml.

1. Firstly open app\code\core\Mage\Catalog\Block\Navigation.php, copy all the contents and create a new file locally. So that would be: app\code\local\Mage\Catalog\Block\Navigation.php

2. Look for a function on line 93 called getCurrentChildCategories() and comment out the function, replacing it with the following:

$layer = Mage::getSingleton('catalog/layer');
$category   = $layer->getCurrentCategory();
/* @var $category Mage_Catalog_Model_Category */
$collection = Mage::getModel('catalog/category')->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('is_anchor')
->addAttributeToSelect('image')
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
->setOrder('position', 'ASC')
->joinUrlRewrite()
->load();

$productCollection = Mage::getResourceModel('catalog/product_collection');
$layer->prepareProductCollection($productCollection);
$productCollection->addCountToCategories($collection);
return $collection;

Save and upload this file. When a local file is uploaded, it is used instead of the core file.

3. Enter the following code into the subcategory.phtml file that we created in the first part of the tutorial. Make sure it occurs within the foreach statement and inside the getIsActive() check:

<img src="<?php echo $_category->getImageUrl() ?>" width="90" height="90" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" />

You can now visually display your category’s subcategories in a very simple way. Keep checking back for more of our Magento Tutorials here at Ecommerce Web Design.

Categories: Magento Tutorials Tags:

Blog Software for Magento

Posted on: 15th Jul 2010 By: Adam Moss No Comments

At Ecommerce Web Design, we’re big fans of using Wordpress as blogging software which can be installed alongside Magento seamlessly, and provide a clean, open-source blogging solution. It’s free, easy to install, accessible and literally bursting with plugins.

However if you want another solution which integrates into the same backend as the Magento one, I’d recommend the Aheadworks Free Blog extension. It comes with large amounts of customisation, SEO-friendly links and pretty much all the standard features that you’d find with Wordpress – you can even enable RSS feeds with it too. There’s categories, comments, users and a nice TinyMCE editor to write your post with.

Blog

Aheadworks make a great range of quality extensions, most of which they sell for reasonable prices. The best thing about the Magento Blog is that it’s completely free to download and use – I guess it would have to be to compete with Wordpress.

So which one would I recommend? Well, I do think that Wordpress is not only the best blogging tool on the Internet, but it’s also possibly one of the best CMS systems available anywhere. This very blog is written in Wordpress and the possibilities are endless. However if you’re after a simple, no-fuss and manageable solution and want to keep everything in one place, I would absolutely put forward the Aheadworks solution. But Wordpress will always be king I’m sure…

Categories: Magento Tags:

One Magento Installation on Multiple Domains

Posted on: 12th Jul 2010 By: Adam Moss 6 Comments

Plesk is a terrific control panel for multiple reasons – it allows complete administration for all of your websites that are hosted there. This includes the setup of SSL certificates, local database access, SSH access, the ability to switch domains off at the flick of a switch and much more. By much more I’m talking about ‘Domain Aliases’.

It has become an increasing requirement for me to have multiple domains  using the same Magento installation, and those multiple domains show different websites that are set up on that installation. I have domain1.co.uk which holds the Magento Installation, I also have domain2.co.uk which is a website on that Magento Installation. Okay so here’s how you do it…

1. Point DNS – Point the DNS A Record of domain2.co.uk to the IP address of domain1.co.uk.

2. Create Domain Alias – In Plesk, go to the domain overview area for your version of domain1.co.uk and click on ‘Domain Aliases’. Now click ‘Add Domain Alias’ and type in the name of the website (without the http://www part). So I type in domain2.co.uk.

Domain Alias

3. Create Website in Magento - In the Magento Admin area go to System > Manage Stores. Click on ‘Create Website’ and enter the name of the domain into Name field. You also need to enter a code to identify the website (you’ll need this later) – I just went with domain_2. As this isn’t my4.  primary domain, I put the sort order as 2. You should also create an associative store and store view for this new website in the same way. Read my earlier post about websites/stores/store views for more information.

New Website

4. Change the Base URL - Go to System > Configuration > Web. Change the configuration scope (top left) to the secondary website (domain2.co.uk). You now need to change the secure and unsecure Base URL to the new domain, without forgetting to put the forward slash at the end of both.

Base URL

5. Update the .htaccess – Now that everything’s in place it’s simply a case of adding some code to the bottom of your main Magento .htaccess file so that Magento knows to load your new website when accessed from that domain. The code for my website domain2.co.uk would look like this:

SetEnvIf Host www\.domain2\.co.uk MAGE_RUN_CODE=domain_2
SetEnvIf Host www\.domain2\.co.uk MAGE_RUN_TYPE=website
SetEnvIf Host ^domain2\.co.uk MAGE_RUN_CODE=domain_2
SetEnvIf Host ^domain2\.co.uk MAGE_RUN_TYPE=website

You can see at the end of line 1 & line 3 that the website code I defined earlier as ‘domain_2′ has been appended accordingly. Save your .htaccess file and upload (or just save it if you’re doing it through Plesk). Without sounding like the official advocate of all that is Plesk, it really is a good way of configuring the server settings of your Magento site and can save you a lot of time and energy.

Thanks for reading the Magento Blog at E-commerce Web Design, I’d love to know how you all get on with creating your additional Magento URLs so please leave a comment and let me know.

Categories: Magento Tutorials Tags:

Enable Modern Theme Easily

Posted on: 8th Jul 2010 By: Adam Moss No Comments

We’ve had our fair share of posts about the Modern theme, including various ways to install it and the problems that came along with 1.4.0 when it didn’t apparently sit properly. One way around it was to move the modern theme contents into the /base folder and change the package to the base package. This worked perfectly well and was a nice solution. Want a nicer one?

After you install Magento, simply go to System > Design

Modern Theme

Click on ‘Add Design Change’ and simply choose ‘modern’ from the dropdown list. Save this and look at the frontend, you should be greeted by the nice, sleek and grey-looking modern theme. Much easier. You can obviously continue to customise themes for different websites or store views in the usual System > Configuration > Design area.

I declare this the last ever post about the Modern Theme at the Magento Blog by Ecommerce Web Design. Next week, due to high demand, I’ll be showing you how to use multiple domains on the same Magento installation with Plesk.

Categories: Magento Tips Tags:

Delete Stores / Websites in Magento

Posted on: 6th Jul 2010 By: Adam Moss 2 Comments

In a recent project I had to remove websites, stores and store views in Magento because I simply didn’t need them any more. I couldn’t wait to get into that admin area and clear it all up. It’ll be nice and simple, I’ll just open the store view and look for the nice red ‘Remove Store View’ button in the top right corner…. *gasp*

Several hours followed my collapse, luckily I only suffered minor concussion from the fall. However when I came around the cold dark truth of what I was hoping was a nightmare became very real indeed. There is no way of removing stores that you create in Magento.

Luckily it’s actually very easy to remove these stores/websites/store views in the database – phpMyAdmin gives you the ability to delete things! I guess you could use any other database administration program too. There are 3 tables to look for:

  1. core_website to remove websites
  2. core_store to remove store views
  3. core_store_group to remove stores

phpMyAdmin

I should mention that you should NOT DELETE the first row of each of these tables. Now I’d like to ask Magento to include the delete button in the next release to free us from this madness.

Categories: Magento Tutorials Tags: