Magento: change applied attribute product types

Sometimes it is necessary to change the product type(s) an attribute is applied to in Magento. A common example is, that you designed and implemented an attribute for a configurable product, because you thought its real world value is equal over all child manifestations. But after a while you realize, that there are differences that you […]

Magento “Invalid website id requested.” error in backend on product save

Today I got a error in the Magento  backend telling me, that I have requested an invalid website_id (Invalid website id requested.), when I tried to save a product. The problem was, that I had deleted unused websites and stores over the Magento backend. Unfortunately Magento seemed to keep the relation between website and product, although […]

Run multiple Magerun instances at once

In the past I already wrote articles about the very genius tool Magerun from Netz98, that I nearly use on every Magento project. Recently I had the challenge to run three instances of Magerun on the same physical server with only one shell account. This was necessary because I ordered a big cluster from maxcluster for […]

Magento change attribute scope in setup script

This code snippet shows how to change attribute scope in a setup script:

And the config.xml:

 

Remove empty rows from CSV

Recently I had to remove empty rows from a Magento ImportExport product export CSV file (see https://www.webguys.de/magento-1/turchen-19-produktimport-mit-der-importexport-schnittstelle). The format of these files is really complex. The problem was, that I did a cleanup of the product data inside the file. As a result of this there where empty rows. So I had to eliminate them. […]

MySQL server has gone away error fix for Magento

Today I wanted to test a tiny shell script, that didn’t do such magic stuff. It only generates a few websites, stores and storeviews and associates approximately 200 products to 4 websites. When I ran it locally I had no problems at all. But on the staging server I got the following error message when […]

Associate products to all websites more performant

Recently I had to associate all products of a shop to newly created websites in a setup shell script (Associate products to all websites). This could have been implemented like that:

A much better approach was it to use class Mage_Catalog_Model_Product_Action like that:

This was much more performant, than saving each product all the time. By the […]

Get all attribute options

To get all attribute options from a Magento dropdown attribute (select field) you can use the following snippet:

That gives you an array like that:

This can be used as source for a system config field for example. See my blogpost about Category dropdown element. To get a specific value by given label, you can […]