Sunday, February 8, 2009

Joomla/VirtueMart and restrict content

My customer requested that certain parts of VirtueMart only would be accessible if you are registered user. This is pretty easy when you have found the proper object to call. You need to retrieve the user object and then check if it has an ID:

$user =& JFactory::getUser();

if ($user->id > 0)
{ /* do code */}

That's all to it. When you have gotten the user-object you can of course access a whole lot more information which is documented in the user class. Below are two interesting links if you need to find out more.

http://api.joomla.org/Joomla-Framework/User/JUser.html

http://www.jlleblanc.com/joomla/Tutorials/JUser_tutorial_for_Joomla!_1%115/

Monday, February 2, 2009

VirtueMart not showing all related products...

Today I found a little bug in VirtueMart 1.13 or perhaps it's a feature. When using related products on your product page only 4 items of related products would show. If you modify
administrator/components/com_virtuemart/html/shop.product_details.php

at line 85:

$q .= "AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, '', ',' )) LIMIT 0, 4";

to

$q .= "AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, '', ',' )) ";

you remove this silly limit. Easy! :)

Sunday, February 1, 2009

VirtueMart experiences while building a pretty large site

Currently I am building a website with a whole lot of products and categories... well to be exact there is currently 22623 products and a total of 6973 categories! Yes, that's a whole lot of categories and some might think it sounds crazy but it gives an organized look and the number of products will rise up and probably beyond 100000 but the categories will probably remain the same.

Initially I wasn't aware of that the customer wanted to have these huge amounts of data in the system. Having run systems with less than 1000 products and 20 - 30 categories or so I figured that this customer was about the same ratio. Was I up for a big surprise...

The import of the product was done using a custom application built in Delphi that took the Excel-files and added the data directly into the MySQL-database. The categories was worse. They didn't exist! Adding all of them in VirtueMart would have taking forever as well. We also did experience a whole lot of slowness over the Internet since the test-site was located far away from us and due to issues with VirtueMart and Internet Explorer 7. I decided to create a small GUI in Delphi now titled "WorkMan ViMA", except a public release in a few months time. It allowed my customer to add multiple categories entered in a textbox and just selecting appropriate parent category in a treeview. Adding all of those categories was suddenly quite easy and fast.

The next big issue was the category menu at the frontpage - it was dead slow. After trying all possible menus and some Ajax-trees I found a plaintext XHTML-tree that was rock solid and fast as a racecar. I forgot the link but if I find it I will update this blog.

Issues with administration in Internet Explorer was also a nightmare. Operation aborted error popped up all the time. Out of chance we tried Firefox - what a difference! It actually works okay in there now. Future customers will have to download and install FF and use it for administration.

While working with products it occured that the search-possibilities aren't quite optimal when you have more than 10-20 categories or a whole lot of products. Hopefully someone is looking at this and provide a fix in a future update. I will look around for tweaks but I am not sure I will find one. Otherwise I will take a shot at adding better search possibilities than those that exists today.

Well, that's my initial take on VirtueMart and a whole lot of data. Expect to read more about it soon.