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

Magento Tutorials

Archive for the ‘Magento Tutorials’ Category

Creating a YouTube Video Tab

Posted on: 22nd Jul 2010 By: Robert Kent No Comments

For this tutorial, you will need the modern theme installed.

What we are going to do is to add an attribute to our attribute set where you can embed the youtube video code. This will then display on the front end of the website for your products.

The files you will need to create/edit are:

- app/design/frontend/default(or base)/default/catalog/products/view/youtube.phtml – create

- app/design/frontend/default(or base)/modern/catalog.xml – edit

First of all create your attribute – we’ll make it a textarea and call it youtube. Give it the settings shown in the image. We’ll then add it to our attribute set.

(Note: I was working on a 1.3 version of magento and due to a small bug I needed to use the description tab and  block – it should work for you if you created the new files. )

Secondly you need to paste the following code into your youtube.phtml file.

<?php if ($this->getProduct()->getYou_tube()) { echo "<div>".$this->getProduct()->getYou_tube()."</div>"; } ?>

Lastly all you need to do is set up a new tab in your xml file. Paste in the following code.

<action method="addTab" translate="title" module="catalog"><alias>description</alias><title>Featured Video</title><block>catalog/product_view_description</block><template>catalog/product/view/description.phtml</template></action>

That’s it! Now all you have to do it paste in the embed code from youtube and you can enjoy a nice product video in a tab! Happy days.

Categories: Magento Tutorials Tags:

PayPal Ignores Magento Delivery Charge

Posted on: 20th Jul 2010 By: Luci Smethurst No Comments

Picture the scene – all is going well, the site has launched and is happily taking orders just fine.. until.. one day, one order comes in strange and the packaging hasn’t been taken into account on the PayPal end. But it only happens once so you hope it was a glitch and move on.

Then it happens again, a few orders down the line.

You try to track the problem, but can’t recreate the error consistently.

Well… the problem and solution have been found! The error only seems to occur when a customer registers and uses PayPal standard – this causes PayPal to not take for the shipping, and so Magento sees the full amount hasn’t been taken for and doesn’t send an order confirmation. Very much less than ideal. We found the solution whilst browsing the Magento forum – you can see the original thread and solution as posted on the forum by clicking here.

The problem? Just five errant files:

  • app/code/core/Mage/Paypal/Helper/Data.php
  • app/code/core/Mage/Paypal/Model/Standard.php
  • app/code/core/Mage/Paypal/Model/Api/Standard.php
  • app/code/core/Mage/Paypal/Model/Api/Abstract.php

Now, you might think it would be as easy as just replacing those core files, but there is one important thing to remember: you should never edit core files. It’s a better practice to create local copies and one we recommend at ecommerce web design.

Step 1 – Open up your app/code folder, and create a new folder called “local”.

Step 2 – Duplicate the exact folder structure for the new files within the local folder, so the first file would be at app/code/local/Mage/PayPal/Model/Helper/Data.php

Step 3 – Upload your new local files. Bingo. Thanks for reading our latest Magento Blog!

Download the fixed PayPal files

Categories: Magento Tutorials Tags: ,

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:

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:

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: