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.

Multiselect Options Text

To render the text-values of an multiselect in a BE-grid:

 

Send a file header in controller (file download)

To return a downloadable file in a controller action, you have to send a file header in controller like that:

 

Image Grid Column Renderer

To show product image previews in Magento Backend, you have to add a image grid column renderer block first:

Afterwards you can add images in a Backend grid block class (f.e.: descendant of Mage_Adminhtml_Block_Catalog_Product_Grid) like that (in _prepareColumns):

Widget definition for BE form fields in Magento

The general widget definition for BE form fields in Magento is:

The following snippets show how to define different form fields for the widget form: Template selector:

Fixed template:

Text input:

Enable / disable select:

Multiselect (customer groups):

Category Selector:

To determine the category ID and load the […]

Delete users in Magento frontend

If you need the possibility to let the users delete their own accounts, you can use the following snippet in a corresponding controller or observer to delete users in frontend:

 

Add JavaScript or CSS in Block class

 To add JavaScript or CSS files to the head section of the resulting HTML page, you can add something like this to the _prepareLayout function of a Block class:

As you can see, we can use the layout model to get the head block an use its functions to add files. This doesn’t work inside of […]