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

Archive for the ‘Magento’ Category

Create a Tax Display Switcher

Posted on: 1st Sep 2010 By: Robert Kent 1 Comment

Here at E-commerce web design we do our best to find useful implementations of certain features that we believe an Ecommerce website design should contain. I have recently come across an issue that I thought Magento would have solved by now – in fact it was something that I thought Magento would have in-built anyway…but alas a few hours of searching later and I can’t find what I need.

The functionality that I was looking for was a TAX/VAT display switcher – much like the switcher that you have for stores and currencies.

What magento allows you to do by default is to allow you to choose in the admin section whether you would like the customers to see prices including VAT, excluding VAT or showing both.

As I couldn’t find this functionality I decided to make it up – However this is not the proper way to do it – just a temporary solution that is not suitable for a live store.

Firstly let me explain my implementation, I am using text links with a parameter to pass the chosen display style to my script. This does not however mean that you cannot use a drop down list. I’ll simply let you know what you need to change in order for this to work as a drop down.

Right then – Step one: – Create your changevat.php file and add it to your root layer.

Inside your changevat.php simply paste the following (if you are using a drop down with a form then replace all instances of $_GET with $_POST).

<?php

require_once 'app/Mage.php';
Mage::app('default');

if(isset($_GET['vat']) && isset($_GET['page'])){

$vat = $_GET['vat'];
$page = $_GET['page'];

if($vat == "excl"){
$display = 1;
} else if($vat == "inc"){
$display = 2;
} else if($vat == "both"){
$display = 3;
} else {
$error = "yes";
}

if($error != "yes"){
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->query("UPDATE core_config_data SET value='$display' WHERE path='tax/display/type'");
header("Location: $page");
} else {
header("Location: $page");
}
}

?>

As you will see there is not that much protection in this script apart from the fact that it will only take those 3 values (hence the long-handed way of writing it). If you wanted to add some more security you can do but for our purposes its good enough.

What you will see in the script is the connection to the database – the script edits the database and replaces the value with whatever is selected.

Excluding Tax = 1

Including Tax = 2

Show Both = 3

It then throws the user back to the page they were originally on with the change in tax display.

To initiate this script you simply need to either do the $_GET parameter version as I did or use a form and change all the $_GET to $_POST in the changevat,php file.

Here is the $_GET version:

Show VAT <a href="/changevat.php?vat=inc&&page=/">Inc</a> / <a href="/changevat.php?vat=excl&&page=/">Excl</a> / <a href="/changevat.php?vat=both&&page=/">Both</a>

Here is the $_POST:

<form action="/changevat.php" method="post">
<select name="vat">
<option value="excl">Excluding VAT</option>
<option value="excl">Including VAT</option>
<option value="excl">Both</option>
</select>
<input type="hidden" name="page" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
<input type="submit" value="Change Display" />
</form>

Now this functionality is very limited as it sets the database rather than a session cookie for the user.

What I suggest is using this as a base and then tying it in with session variables rather than database values. This is what I’m working on currently but if anyone has any suggestions please let me know!

Thanks for visiting our magento blog – home of the magento fox!

Any questions please leave a comment!

Categories: Magento Tags: ,

Magento Login with OpenID

Posted on: 31st Aug 2010 By: Adam Moss 2 Comments

Magento is without doubt the leader of open source ecommerce period. It’s the worlds fastest-growing ecommerce platform and appears to be fully in tune with all of today’s latest SEO and Web 2.0 standards. It therefore surprises me that Magento doesn’t yet include the ability to accept OpenID by default. I’m sure that integrating this functionality wouldn’t be a huge problem for the Magento development team as it is becoming increasingly used across the Internet.

For those of you who are unfamiliar with OpenID, it’s basically a way of safely logging into many different website with the same username and password, thus eliminating the need to have, as I do, 500 different username and password combinations for every website that I use. Think of it as having the same key to open all the doors and windows to your house, your shed, your car and your work office. Imagine how much simpler life would be?

RPX Logos

The good news is that a Magento Connect developer has already enabled an extension which allows swift login with your AOL, Google, Facebook, MySpace, Yahoo and other websites… it also includes OpenID! You can download it from here: http://www.magentocommerce.com/magento-connect/amitshah2007/extension/3720/rpx_sign_in

RPX sign in is very easy to install and configure and gives you the opportunity to allow certain website accounts to login to your Magento frontend.

Thing is, while Magento is clearly loving the fact that such a huge community of developers are constantly adding fantastic new features to their product, there are some things which Magento will need to add as standard to stay ahead of the competition, and one of those things in my opinion is OpenID. Thanks for reading the Magento Blog at Ecommerce Web Design.

Categories: Magento Tags:

The Magento EAV Database Structure

Posted on: 19th Aug 2010 By: Adam Moss No Comments

Those of you that have ever tried to bring back data directly from the Magento database will know that it’s not straightforward at all. For example, you can’t go into the product table and bring back a product of your choice. This is due to to the EAV architecture, something that Magento has introduced to add extra security to how data is called and processed.

For those developers who have spent hours trawling through the Magento database for whatever reason, you’ll most likely have become very familiar with the large number of EAV tables that are contained within it. Until recently I actually had no idea what this stood for and indeed what the purpose of EAV was.. for those of you that have done object-oriented programming it will seem familiar, but actually the concept is completely different.

EAV, or Entity, Attribute, Value is a way of storing entity data that is very different in a way that makes them very similar. In normal OO circumstances if you’d have a product table, with many attributes such as price, colour, description etc, and these attributes would obviously have values such as £9.99, blue and ‘What an awesome price for a blue sportscar’.

Entity

The entity is a major factor that is dealt with in ever store. Created in eav_entity, an entity includes things such as:

  • Products
  • Categories
  • Customers
  • Orders
  • Invoices

Attribute

Belonging to each entity is a set of attributes which make up the data for it. These attributes are all kept in eav_attribute and eav_entity_attribute for every type of entity. This means that you’ve got things such as ‘Customer Name’ and ‘Product Price’ sitting right next to each other in the same table. The entity_type_id is the reason why each attribute can be found so easily!

Value

I think you’ll be able to guess that the value is simply the raw data that is linked with each attribute. This type of data obviously is the main reason why databases become so huge – particularly if you have 10,000 products and 80,000 customers… but then you’ll be too rich to care!

The reason why EAV is used is due to the fact that it is much more flexible that normalized databases from the OO days. Entities and attributes can be added efficiently every time, which works well for Magento – an architecture which is ever-expanding (an ever more complicated). The main downside is the slowness that every Magento developer will be aware of – having so many adjoining tables makes the loading of data a slightly longer process.

My advice is to get used to the EAV architecture and the huge number of tables that are used for every single entity because it is here to stay. Get into phpMyAdmin or Sequel Pro and have a good look round at the architecture. In theory it’s quite difficult to get your head around, but actually it’s not so bad! Thanks for reading the Magento Blog at Ecommerce Web Design.

Categories: Magento Tags:

Magento in a Subdirectory Error

Posted on: 11th Aug 2010 By: Robert Kent No Comments

Recently we installed magento 1.4.1.1 into a subdirectory and we presented with the following error:

“Fatal error: Call to a member function toHtml() on a non-object in /var/www/vhosts/xxx/httpdocs/shop/app/code/core/Mage/Core/Model/Layout.php on line 529″

The main reason for this error is quite simple yet something of a bug. Don’t bother going to the php file in question – you should not change anything there.

In the newer versions of magento they have changed the way childHtml and therefore Block elements are called out. They now require a name feature. When magento is installed it uses the default/default theme. This is where the error comes from.

In your default/default/layout/page.xml you will find a line (possibly line 91) that reads like this:

<block type=”core/profiler” output=”toHtml” />

It should read like this:

<block type=”core/profiler” output=”toHtml” name=”core_profiler” />

With the addition of this name attribute all works well – you can even see that it is meant to have it – because if you go to your “base” equivalent you will see the correct line written there.

After you have edited this, clear your cache and your new magento installation should be up and running a treat!

Thanks for visiting our magento blog at ecommerce website design!

Categories: Magento Tags: ,

New Version of Magento

Posted on: 28th Jul 2010 By: Robert Kent 1 Comment

It’s that time again! A new version of magento is out and about – terrorizing your neighborhood! It’s called 1.4.1.1 – not as catchy as the “beast of Bodmin moor” but what are you gonna do?

Some of the major changes in this one you can find here.

But from a quick skim through of the release notes it seems there are a lot of fixes based around the stock status, quantity and payment methods. There’s always a good number of fixes and improvements in every release note, it’s surprising the thing works as it is!

Is this another spit and polish or have they really capped off Magento’s Oil Leaks?

What I would like to see soon is a better method of backing up the data for magento – perhaps a built in folder duplicator that will create and entire backup – DB and all – every time you run your mage_all_latest.

All I know is – I’m having trouble upgrading from 1.4.0.1…let’s see if they fix that in 1.4.1.2…

Thanks for checking out our magento blog here at ecommerce website design – home of the magento fox!

Categories: Magento Tags: