Tag: Magento

  • Error 500 applying upgrades in Magento Downloader

    Inspecting the error log, the 500 error embedded in the downloader console is the result of a php timeout:

    mod_fcgid: read data timeout in 45 seconds, referer: https://www.<omitted>
    (110)Connection timed out: mod_fcgid: ap_pass_brigade failed in  handle_request_ipc function, referer: https://www.

    According to Plesk Article ID: 127621, FcgidIOTimeout should be the same as PHP’s max_execution_time unless the latter is set to 0.

    From Plesk 12.5 control panel for a domain use Apache & nginx Settings to add the following directive to both http and https, which increases the FcgidIOTimeout from 45 to 120 seconds :

    <IfModule mod_fcgid.c>
        FcgidIOTimeout 120
    </IfModule>

    Simply OK this and re-run the Magento Downloader again.

    Note: at the time of writing the Magneto Connect site is very slow, which may be the cause of this timeout.

  • After upgrade to Magento Downloader to 1.9.2 no upgrades are available

    Following an upgrade to Magento Downloader 1.9.2 I found that the Magento Connect (Downloader) “check for upgrades” returned nothing (quickly) and the mage upgrade community [package name] gave the following error:
    Error:
    upgrade: Package community/[package name] failed: Unknown cipher in list: TLSv1
    This is caused by the OpenSSL library being out of date, so either update it, or comment out line 377 in downloader/lib/Mage/HTTP/Client/Curl.php like so:
    //$this->curlOption(CURLOPT_SSL_CIPHER_LIST, ‘TLSv1’)

    Adendum: for 1.9.3.2 and 1.9.3.3 the fix is different:

    in /downloader/lib/Mage/HTTP/Client/Curl.php line 371

    change:
    protected function makeRequest($method, $uri, $params = array(), $isAuthorizationRequired = false, $https = true)

    to:
    protected function makeRequest($method, $uri, $params = array(), $isAuthorizationRequired = false, $https = false)

    (Changing the connection method to HTTP in Magento Connect Manager does NOT work.)
    If the downloader is itself updated, this “fix” will need to be repeated.

  • Adding mcrypt to Plesk 12

    The php mcrypt module, required by Magento, wasn’t present on our Plesk VPS. Here’s how to add it from SSH:

    (1) Add the repository. For example, to add EPEL:
    rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

    (2) Install the php-mcrypt module:
    yum install php-mcrypt

  • Magento 1.6 Customer Address Edit Error Invalid backend Model Specified

    Following an upgrade from Magento 1.5 to 1.6 the error:
    Invalid backend model specified: customer_entity/address_attribute_backend_region
    occurs during customer address edit or checkout address entry.
    This is because in the eav_attribute table, backend_model values are incorrect. Fix with the following SQL:

    UPDATE `eav_attribute` SET `backend_model` = 'customer/entity_address_attribute_backend_street' WHERE `attribute_code` ='street' LIMIT 1 ;
    UPDATE `eav_attribute` SET `backend_model` = 'customer/entity_address_attribute_backend_region' WHERE `attribute_code` ='region' LIMIT 1 ;
  • Editing Magento’s Invoice & Despatch PDF Layouts

    Magento Invoice and Shipping (Despatch) PDF files are delivered with a reasonable layout, already suited toA4 printing, but benefit from some layout improvements, increasing font sizes, and lightening the greyscale boxes in the interests of readability.
    Take a copy of the relevant core files and place them in:

    /app/code/local/Mage/Sales/Model/Order/Pdf

    The relevant files are Invoice.php & Shipment.php, but Abstract.php contains functions common to both, and the subdirectory Items contains formatting for the line items of each document type.
    The following snippet can be used to format database values as currency values:

    $formattedPrice = Mage::helper('core')->currency($Price,true,false);
  • Magento claims it is in Maintenance Mode (and it isn’t)

    Assuming that Magento is not actually in maintenance mode (i.e. downloader is not being used) then the following error is the result of a lock file not being removed, probably as the result of an ungraceful exit from the downloader:

    Service Temporarily Unavailable
    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

    To take Magento out of maintenance mode, just delete the file:

    maintenance.flag

    from the Magento root.

  • 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.

  • 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.

  • reCAPTCHA for Magento

    Well done Fontis for integrating reCAPTCHA into Magento to prevent SPAM through the contact form and “social” pages. About time!
    Well though-out and integrated beautifully into admin.
    Keys are required from reCAPTCHA andthe extension can be installed through Magento Connect using the extention key on the Magento Extention page.

  • Magento

    Since I last looked (around 9 months ago, I think) the Magento web store project seems to have shaped up nicely. It is certainly prettier than OSCommerce, but more importantly they have kept the code and the presentation separate using – of course – CSS.

    It is written in PHP, and has a growing collection of add-ins, so I’ll be seriously evaluating it as an alternative to OSC for the Oriental Food Shop.