Make additional product attributes available over REST-API

To do this you only have to add a api2.xml in your modules etc folder that puts the necessary product tags into the node /config/api2/resources/product/attributes (xPath): <config> <api2> <resources> <product> <attributes> <sheldon_ean>EAN</sheldon_ean> <sheldon_articlenbr>Articlenumber (Model)</sheldon_articlenbr> <sheldon_stylenbr>Stylenumber</sheldon_stylenbr> <sheldon_color>Color</sheldon_color> <sheldon_size>Size</sheldon_size> <sheldon_material_description>Material Description</sheldon_material_description> <sheldon_supplement>Supplement</sheldon_supplement> <sheldon_carehints>Carehints</sheldon_carehints> <sheldon_is_aboable>Is aboable product</sheldon_is_aboable> <sheldon_is_sale_product>Is sale product</sheldon_is_sale_product> <sheldon_is_new_product>Is new product</sheldon_is_new_product> <sheldon_is_reddot_product>Is reddot Product</sheldon_is_reddot_product> <sheldon_reddot_years>Product Reddotyears</sheldon_reddot_years> […]

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: $fileName = ‘mm_actioncodes_export_’.date(“Ymd_His”).’.csv’; $fp = fopen(Mage::getBaseDir(‘var’) . DS .’export’ . DS . $fileName, ‘w’); fputcsv($fp, $codes, ‘;’, ‘”‘); fclose($fp); $this->_prepareDownloadResponse($fileName, array( ‘type’ => ‘filename’, ‘value’ => Mage::getBaseDir(‘var’) . DS .’export’ . DS . $fileName, //’rm’ => true […]

Trigger layout handle in another layout handle

In most cases you don’t want to write the same layout declaration twice. With the following snippet you can trigger a once written layout handle in other layout handles. So you can reuse the declaration. <modul_controller_action> <update handle=”modul_controller_action”/><!–layout handle to trigger–> </modul_controller_action>

Image Grid Column Renderer

To show product image previews in Magento Backend, you have to add a image grid column renderer block first: <?php /** * * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * It is available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php […]

Add a main menu entry in Magento

This is how you can add a main menu entry to the Magento main menu in your modules adminhtml.xml: <?xml version=”1.0″ encoding=”UTF-8″?> <config> <menu> <sheldon_wysiwyg module=”sheldon_wysiwyg”> <title>WYSIWYG</title> <sort_order>88</sort_order> <children> <test module=”sheldon_wysiwyg” translate=”title”> <title>Test</title> <sort_order>0</sort_order> <action>adminhtml/sheldon_wysiwyg/data</action> </test> </children> </sheldon_wysiwyg> </menu> <acl> <resources> <all> <title>Allow Everything</title> </all> <admin> <children> <sheldon_wysiwyg> <title></title> <sort_order>70</sort_order> <children> <posts> <title>Manage Posts</title> <sort_order>0</sort_order> […]

Widget definition for BE form fields in Magento

The general widget definition for BE form fields in Magento is: <?xml version=”1.0″?> <widgets> <widget_identifier type=”blochtype/like_in_normal_blocks” translate=”name description” module=”modulname”> <name>Widgetname</name> <description>A useful description</description> <is_email_compatible>1</is_email_compatible> <parameters> <!– field definition goes here –> </parameters> </widget_identifier> </widgets> The following snippets show how to define different form fields for the widget form: Template selector: <template translate=”label”> <label>Template</label> <visible>1</visible> <type>select</type> […]

Template Marker

Here is a collection of marker that can be used in email templates, cms pages and static blocks. Get system configuration fields {{config path=”web/unsecure/base_url”}} Customer data {{var customer}} -> print all customer data {{var customer.ID}} {{var customer.email}} {{var customer.firstname}} {{var customer.lastname}} {{var customer.name}} {{var customer.password}} {{var customer.created_in}} -> store name where customer was created in {{var […]

Directly query database

To directly send queries against the database: //$read = Varien_Db_Adapter_Mysqli extends Zend_Db_Adapter_Mysqli extend Zend_Db_Adapter_Abstract $read = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’); $query = ” SELECT SUM(`grand_total`) AS `grand_total`, SUM(`subtotal`) AS `subtotal`, SUM(`tax_amount`) AS `tax_amount`, SUM(`discount_amount`) AS `discount_amount`, SUM(`shipping_amount`) AS `shipping_amount`, FROM `sns_salesreport_monthstats` WHERE `year` = $year “; $data = $read->fetchRow($query); //fetches only the first row // or multiple rows: $sql […]