22 Jan

Display Attributes on Invoice or Packing Slip in Magento

Add this to Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php, replace ATTRNAME as appropriate. public function draw() { ... $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('ATTRNAME')); if ($product) { $lines[0][] = array( 'text' => Mage::helper('core/string')->str_split($product->getData('ATTRNAME'), 15), 'feed' => 305 ); } Then add this to Mage/Sales/Model/Order/Pdf/Invoice.php, replace ATTR_TITLE as appropriate and OFFSET with the left offset. /* Add table head */ ... $page->drawText(Mage::helper('sales')->__('ATTR_TITLE'), … Continue reading

18 Jan

Fast bulk product status change with Magento

If you have a large catalogue, using some standard features are simply impractical to use. Recently, we needed to disable an entire range of products based on its SKU - via the backend, bulk status changing 5000 products will take hours, but fortunately SQL is a spot more lightweight. In the code below (to be … Continue reading

18 Jan

Speed up Magento, product import, export and general via the database

If your Magento product imports and exports certainly aren't as speedy as they used to be, it could be that the database table is just filling up with old records. There are a few to look at. TRUNCATE dataflow_batch_export; TRUNCATE dataflow_batch_import; TRUNCATE log_customer; TRUNCATE log_quote; TRUNCATE log_summary; TRUNCATE log_summary_type; TRUNCATE log_url; TRUNCATE log_url_info; TRUNCATE log_visitor; … Continue reading

13 Jan

Magento/WordPress injection vulnerability

We had been recently contacted by an agency (non-Sonassi Hosting) keen to resolve a Magento redirect on checkout bug. We quickly realised after inspection that the site had been subject to an all-too-common POST injection vulnerability. Discussing ultimate prevention is beyond the scope of this post, but you can check for tell tale signs. If … Continue reading

18 Dec

Quick script to batch create Magento categories

A site we administer with a reasonable amount of SKUs (far in excess of 100,000), needed some quick category manipulation for a series of new data to be dropped in. The new information had a desired category tree that had to be built up quick, but with over 600 categories to be created, human effort … Continue reading

17 Dec

Quick script to export Magento categories with IDs

If you are after a quick method to get all the category ID's for your categories for some Excel lookups (for new data imports), then this quick PHP script should help you out: <?php define('MAGENTO', realpath(dirname(__FILE__))); require_once MAGENTO . '/app/Mage.php'; Mage::app(); $category = Mage::getModel('catalog/category'); $tree = $category->getTreeModel(); $tree->load(); $ids = $tree->getCollection()->getAllIds(); if ($ids) { $file … Continue reading

13 Dec

Speeding up the Magento admin

I've noticed a few people discussing this issue on the Magento Commerce forum, so it might be worthwhile for us to offer a level of assistance (other than the fast Magento hosting we provide already from sonassi hosting). Downloading the following file, SlowManageCategories.zip patch. Extract the zip file and copy Sonassi_All.xml to your ./app/etc/modules/ directory. … Continue reading