Allan Brown

November 25, 2009

Sort by price not working in Magento

Filed under: Magento — Tags: , , , , , , — Allan Brown @ 9:12 pm

I recently added a large volume of products to Magento, however when I then began looking through the product listing, it was acting in a really strange way.

All products were displaying correctly however the order was all wrong.  Instead of being ordered or sorted by price by default as they should of been, the order was all over the place.

After a bit of searching I eventually found the problem is in the Magento cache system and specifically in the Layered Navigation indexes.

Logging in as admin and using the “System->Cache Management->Layered Navigation Indices->Refresh now” option resolved the issue.  However this process took a long time to complete on my server, so some patience may be required.

November 1, 2009

Magento connect pear upgraded wrong Magento site!

Filed under: Magento — Tags: , , , — Allan Brown @ 3:14 pm

When we started working with Magento, we started with a single site which we could being learning from.  Once we were happy that we would continue on this platform and decided we needed a 2nd development environment to work on we created a copy of our current Magento install, changed the DB connection config, and thought that was that.

Last week when I went to upgrade Magento to the latest version, a strange thing happened.  The upgrade through Magento connect (downloader/index.php?A=pearPackages) worked perfectly, it said all was upgraded, but the files that were changed were changed on the wrong site.  I eventually tracked this down to the Magento Connect, and the fact that it has its own static config files (pear.ini) which saves the local Magento path.  This obviously did not change when the 2nd copy of the site was created, so when we then performed the upgrade on the staging version of the site, the live site was upgraded instead.

To fix this, simply delete pear.ini, and it will be recreated with the correct settings automatically.

Threads which reference this issue are:

http://www.magentocommerce.com/boards/viewthread/17165/
http://www.magentocommerce.com/boards/viewthread/56226/

Bit of an odd one!

Adding images to magento using code (Programmaticaly)

Filed under: Magento — Tags: , , , — Allan Brown @ 3:00 pm

Ive been working on automatically adding products to Magento from a 3rd party XML feed.  Its fairly easy to do, however I couldint find much information on how to attach images to a product, and then how to set a product image as thumbnail, small image and base image.

The code to add an image to a product in Magento is:

$product->addImageToMediaGallery($imagePath, array('image','small_image','thumbnail'), false, true, $productData['data_display_name'] . " " . $productData['data_artist_display_name'] . " " . $productData['data_catalog_number']);

It is the array(‘image’,’small_image’,'thumbnail’) which tells Magento that you are wanting to use this image as the small image, thumbnail and base image.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Powered by WordPress