Magento import multiple images in dataflow csv/xml

Sometimes it’s really annoying that Magento only supports one image per product. On the Magento Commerce forum a solution is found:

Now, what you need to do is open the file
app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php
and go to around line 773 and find

$addedFilesCorrespondence = $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
$product,
$arrayToMassAdd, Mage::getBaseDir('media') . DS . 'import',
false,
false
);

and paste the following code right after it
if (isset($importData['media_gallery']) && !empty($importData['media_gallery'])) {
$x = explode(',', $importData['media_gallery']);
foreach ($x as $file) {
$imagesToAdd[] = array('file' => trim($file));
}
$mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
$product,
$imagesToAdd, Mage::getBaseDir('media') . DS . 'import',
false,
false
);
}

Source: http://www.magentocommerce.com/boards/viewthread/224928/P45/



Magento place order slow [FIXED]

The Magento “place order” step can take up to a minute. With thanks to this site I figured out how to fix slow checkouts.

Step 1

Find the file app/code/core/Mage/Rss/etc/config.xml and uncomment/remove:

<sales_order_save_after>
<observers>
<notifystock>
<class>rss/observer</class>
<method>salesOrderItemSaveAfterNotifyStock</method>
</notifystock>
</observers>
</sales_order_save_after>
<sales_order_save_after>
<observers>
<ordernew>
<class>rss/observer</class>
<method>salesOrderItemSaveAfterOrderNew</method>
</ordernew>
</observers>
</sales_order_save_after>

Step 2

Find the file app/code/core/Mage/Downloadable/etc/config.xml and uncomment/remove:

<!–sales_order_item_save_commit_after>
<observers>
<downloadable_observer>
<class>downloadable/observer</class>
<method>saveDownloadableOrderItem</method>
</downloadable_observer>
</observers>
</sales_order_item_save_commit_after–>



Magento upgrade to 1.7

Upgrading Magento Commerce 1.4, 1.5 and 1.6 to 1.7

Magento is a pretty complex program that hasn’t an easy upgrading solution. Because following the standard guides gives quite a lot of errors, I wrote my own upgrade guide with thanks to Duntuk.com and Turnkeye.

For versions lower than 1.4.2, you’d first have to follow the steps from Turnkeye for lower versions.

Pre-upgrading steps

  • MAKE A BACKUP!
  • Install a fresh install of Magento on a subdirectory or other host on a new database (don’t overwrite your own version of course).
  • With the db repair tool from Magento you can compare your own database versus the fresh database you just installed. The db repair tool looks for errors in the database and can upgrade them.
  • Open SSH and remove your cache:
    rm -rf var/cache/*
    rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*

Upgrading steps

  • Chmod the mage file: $ chmod 550 ./mage
  • Upgrade the site (according to Duntuk and Turnkeye):$ ./mage mage-setup .
    $ ./mage sync --force
    $ ./mage list-upgrades #(in order to see if there are upgrades)
    $ ./mage config-set preferred_state stable
  • Start the upgrade
    $ ./mage upgrade-all --force
  • If the upgrade is finished you'll see rows like:
    Package upgraded: community/Mage_Locale_en_US 1.7.0.2
  • Remove cache and sessions
    $ rm -rf var/cache/* var/session/*
    $ rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
  • Visit the homepage which will trigger the upgrade process. It can take up to 30 minutes. By doing it by SSH safes memory:
    $ php -f index.php
  • Sometimes it’s safer to trigger the index.php multiple times until it gives a blank return
  • Than visit the admin and make sure the version number is the number of the upgraded version

Aftercare

Reindex the website if the upgrade is succesful:

$ php shell/indexer.php reindexall

Set all the permissions back:

$ find . -type f -exec chmod 644 {} \;
$ find . -type d -exec chmod 777 {} \;

$ chmod 755 mage
$ chmod o+w var var/.htaccess app/etc
$ chmod -R o+w media
$ chmod -R 777 var/package var/locks var/report var/export downloader

Hopefully your site is upgraded now! If you’ve any questions respond below!

Issues

Error: Mage registry key “_resource_helper/core” already exists

rm -rf var/session/*
rm -rf var/cache/*

If that doesn’t work restart caching tools like Memcached!