Blog

  • Magento 1.3 to 1.5 upgrade notes

    The upgrade to 1.5 has a number of “gotchas” so while I am debugging the process on the test / staging instance, here are a few notes.

    Basic process

    Empty some or all of the log tables as they are potentially huge and are not needed:

    TRUNCATE `log_customer`;
    TRUNCATE `log_quote`;
    TRUNCATE `log_summary`;
    TRUNCATE `log_url`;
    TRUNCATE `log_url_info`;
    TRUNCATE `log_visitor`;
    TRUNCATE `log_visitor_info`;
    TRUNCATE `log_visitor_online`;
    TRUNCATE `report_viewed_product_index`;
    TRUNCATE `report_compared_product_index;`
    TRUNCATE `report_event`;
    TRUNCATE `catalog_compare_item`;
    TRUNCATE `index_event`;

    Backup the 1.3 instance using Magento’s built in backup.

    Edit the resulting .sql file and uncomment the FOREIGN_KEY controls at the top and bottom of the file:

    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

    If the domain or subdomain is changing, do a search & replace e.g. replace www.myshop.com with test5.myshop.com

    Create the new database instance, and execute the SQL from the previous step. Make sure it doesn’t time out, last table created is normally “wishlist_item”

    Yoast Metarobots breaks product maintenance in Magento 1.4+, so remove relevant fields:

    DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'metarobots_setup';
    DELETE FROM `eav_attribute` WHERE `eav_attribute`.`attribute_code` = 'meta_robots';
    update eav_entity_type set additional_attribute_table='catalog/eav_attribute',entity_attribute_collection='catalog/product_attribute_collection' where entity_type_id=4;

    Now FTP the Magento downloader.php onto the target site, check file permissions and execute it with http://test5.myshop.com/downloader.php

    Follow the setup process including specifying the correct database name, user and password.

    Use the same encryption key from the original site – find it in /app/etc/local.xml

    If there are problems with the setup not accepting the admin user / password combination, simply re-run the installer by pointing your web browser at http://test5.myshop.com

    Remember that the original admin user already exists in the database export, so create a temporary one and delete it later.

    Fixing problems

    Can’t access the admin site, gives 404 error

    The database import will have incorrectly sequenced the sites, so run the following:

    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    UPDATE core_website SET website_id="0" WHERE core_website.code="admin" LIMIT 1;
    UPDATE core_store SET store_id="0" WHERE core_store.code="admin" LIMIT 1;
    SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

    Admin site is “white” i.e. CSS not working and plain HTML is displayed

    Delete contents of /var/cache/

    “There are no products matching the selection” when browsing front end

    Wrong customer group ID for users that are no logged in. Execute the following SQL:

    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    UPDATE `customer_group` SET `customer_group_id` = 0 WHERE `customer_group_code` LIKE 'NOT LOGGED IN';
    SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

    No product images

    Check correct permissions and then copy the images directory structure from the source site eg:

    cp /httpdocs/media/catalog/* /subdomains/test5/httpdocs/media/catalog/

    Now login to admin site and run a  re-index on everything, and update all of the caches.

    Error File does not exist: … media/catalog/product/no_selection

    Review the System Configuration and under Catalogue / Catalogue / Product Image Placeholders and add the missing placeholders. Add back in the watermarks too in General / Design / Product Image Watermarks.

  • Binary – ASCII conversion

    This page has bidirectional binary – ASCII conversion. This is useful if you are following @cjsupercomputer.

  • Pressure Cooked Shoulder of Pork

    Ingredients

    2 kg boneless pork shoulder
    2 tablespoon olive oil
    300g mushrooms, thick sliced
    1 onion, diced
    2 carrots, diced
    2 tbsp tomato paste
    500ml stock, either chicken or vegetable
    2 bay leaves
    salt & ground pepper to season

    Method

    Salt and pepper a board, roll the meat on it. Heat 1 tbsp oil in the pressure cooker and brown meat all over. Temporarily remove meat. Fry onion and carrot in the remaining oil until softened. Add tomato paste, stock, and bay leaves. Place roast on top, add sliced mushrooms, cover and bring up to full pressure. Cook for 50 minutes. Reduce pressure using the natural method. Remove meat to rest for 10 minutes. Separate fat from stock and thicken with cornflour to make a gravy.

  • Parsnip and Butternut Squash Soup

    Here is a nice combination of Autumn flavours.

    Ingredients

    2 large onions, halved
    3 large parsnips, peeled and halved
    2 medium butter-nut squash, sliced in half lengthways, de-seeded
    Small handful of lemon thyme
    Olive oil
    Salt and pepper
    1.5 litres vegetable stock
    2 tablespoons crème fraîche

    Method

    Place the vegetables on a baking tray, pour over some olive oil, season and add the thyme. Bake at 180 degrees Celsius for one hour.

    Scrape the flesh from the squash, remove any twigs from the thyme, and blitz the cooked vegetables in a food processor adding the stock a third at a time.

    Put in a pan and bring to a simmer, balance the seasoning, take off the heat and stir in the crème fraîche. Serve.

  • Oatcakes Recipe

    Ingredients

    175g Oat flakes
    150g Butter
    85g Oatmeal
    50g Caster sugar
    40g Honey
    Pinch Salt

    Method

    Melt the butter, mix all of the ingredients together in a bowl to form a stiff dough. Roll out to 6mm thickness and cut out into rounds. Bake at 180 degrees C for approx 20 minutes or until browned. Cool on a wire rack.

  • Carrot and Raisin Muffins

    Ingredients

    375g plain flour
    175g brown sugar
    1 teaspoon baking powder
    1 teaspoon cinnamon
    Pinch of salt
    150ml vegetable oil
    2 eggs, beaten
    250g carrots, grated
    75g raisins

    Method

    Preheat the oven to 180 degrees C.
    Grease a 12 cup muffin tray.
    Combine flour, sugar, baking powder, cinnamon and salt in a bowl.
    Mix together vegetable oil and eggs, then add to dry ingredients. Fold in carrot and raisins; divide into muffin cups. Bake for 25 minutes or until a skewer comes out clean. Cool on a wire rack.

  • Orange Glazed Carrots

    Ingredients

    600g carrots, cut into batons
    2 tablespoons butter
    1 tablespoon honey
    1 teaspoon orange juice
    Pinch salt
    Chopped parsley

    Method

    Cook carrots as usual until tender, drain. Melt the butter in a pan and add honey and orange juice. Stir through the carrots and sprinkle with parsley to complete the dish.

  • Runaway Magento catalogindex_aggregation tables

    I have received a large number of integrity contraint violation errors relating to the catalogindex_aggregation_to_tag table; it turns out that it is one of three tables are related to the Layered Navigation cache:

    catalogindex_aggregation

    catalogindex_aggregation_tag

    catalogindex_aggregation_to_tag

    which quickly become huge even if tagging is not actively used.
    The solution is to Disable Cache Control (beta) Layered Navigation” i the admin panel under “Cache Management” and then refresh the cache.
    All three tables are then emptied and perforamnce is significantly improved.
    There is a lesson to be learnt about using beta code, I guess…

  • Copy or move Magento to another instance

    A quick how-to if you want to copy or move Magento to another database instance, e.g. to create a test site, or move test to live.

    (1) Backup Magento using the built in backup tool. Download and uncompress the resulting SQL script. If changing the server or domain, search and replace “old.mysite.com” with “new.yoursite.com” Execute it to populate the new database instance.

    (2) Copy all Magento files with the exception of the contents of the var/ directory.

    (3) Edit app/etc/local.xml on the target instance and change the database, user and password, but not the encryption key. Also edit downloader/pearlib/pear.ini to correct the absolute paths it contains; no reason why these shouldn’t be relative to the Magento root directory, e.g. “./downloader/pearlib”.

    (4) Execute the following SQL to prevent those nasty “Integrity constraint violation: 1062 Duplicate entry” errors from the log files when adding to the basket:

    TRUNCATE `log_customer` ;
    TRUNCATE `log_quote` ;
    TRUNCATE `log_summary` ;
    TRUNCATE `log_url` ;
    TRUNCATE `log_url_info` ;
    TRUNCATE `log_visitor` ;
    TRUNCATE `log_visitor_info` ;
    TRUNCATE `log_visitor_online` ;

    Now tidy up permissions:

    chmod o+w var var/.htaccess app/etc
    chmod -R o+w media

    That should be it.

  • Up-to-the-minute London signage

    London has up-to-the-minute signage, so much so that when Victoria’s friend took her photo the other weekend, it looked like this…

    London Signage