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:

 

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 […]

Load product attributes more performant

Recently I had performance issues when importing several ten tausend products. The problem was, that I always used the “normal” product entity model to load attribute values. The following snippet shows, how to load product attributes directly instead. Therefore I use the product resource singleton.

Option value position (select value sort order)

This Magento shell script sorts the values of a given attribute after the order of values in a given CSV file (sets option value position).

So it is not necessary to set the values via BE-Interface. The value matching to find the respective option-id is done by using the value of the Storeview specified in REFERENCESTORE and the attribute […]