How to paste sample php code into field comments of system.xml

How to paste sample php code into field comments of system.xml

It’s pretty weird thing that Magento doesnt extract “?>” but does extract “<?php” and so for this purpose you just substitute “]]> Hope it helps someone to save some time :) SyntaxHighlighter.defaults['toolbar'] = false;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.all();if (window.jstiming) window.jstiming.load.tick(‘widgetJsBefore’);if (typeof(BLOG_attachCsiOnload) != ‘undefined’ && BLOG_attachCsiOnload != null) { window['blogger_templates_experiment_id'] = “templatesV2″;window['blogger_blog_id'] = ’32637828′;BLOG_attachCsiOnload(‘item_’); }_WidgetManager._Init(‘http://www.blogger.com/rearrange?blogID=32637828′,’http://fahdshariff.blogspot.com/2011/03/upgrading-to-syntaxhighlighter-30.html’,’32637828′);_WidgetManager._SetPageActionUrl(‘http://www.blogger.com/display?blogID=32637828′,’APq4FmDdmaO1E0AiAntKEHoCeCo1IIbMkhFh8aoj7ANUfzSEK9xRLZIjujI7Ey_m-z4NBCPLh4eEBbhU0zJmXPhGaJLNBnDKBg==’,'AOuZoY5th5qGHtR4Wpx2476uNklp-eN74Q:1320253700709′);_WidgetManager._SetDataContext([{'name': 'blog', 'data': {'title': [...]

Read full story Comments { 0 }
How to get current store’s timestamp

How to get current store’s timestamp

Just use the method below – you dont need any other tricks to play: $currentTimestampProper = Mage::getModel(‘core/date’)->timestamp(time()); P.S.: This simple method proved its reliability on my very own practice ;) SyntaxHighlighter.defaults['toolbar'] = false;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.all();if (window.jstiming) window.jstiming.load.tick(‘widgetJsBefore’);if (typeof(BLOG_attachCsiOnload) != ‘undefined’ && BLOG_attachCsiOnload != null) { window['blogger_templates_experiment_id'] = “templatesV2″;window['blogger_blog_id'] = ’32637828′;BLOG_attachCsiOnload(‘item_’); }_WidgetManager._Init(‘http://www.blogger.com/rearrange?blogID=32637828′,’http://fahdshariff.blogspot.com/2011/03/upgrading-to-syntaxhighlighter-30.html’,’32637828′);_WidgetManager._SetPageActionUrl(‘http://www.blogger.com/display?blogID=32637828′,’APq4FmDdmaO1E0AiAntKEHoCeCo1IIbMkhFh8aoj7ANUfzSEK9xRLZIjujI7Ey_m-z4NBCPLh4eEBbhU0zJmXPhGaJLNBnDKBg==’,'AOuZoY5th5qGHtR4Wpx2476uNklp-eN74Q:1320253700709′);_WidgetManager._SetDataContext([{'name': 'blog', 'data': {'title': 'fahd.blog', [...]

Read full story Comments { 0 }
Creating a new user role programmatically

Creating a new user role programmatically

I’ve been working recently on one enhancement which has involved role creation programming. So, today im sharing my knowledge of that process with you :) First of all id like to mention that all the code that you might need to use in the future is already somewhere in the core files, as a rule, [...]

Read full story Comments { 0 }
How to determine which module, controller and action are loaded now?

How to determine which module, controller and action are loaded now?

Just like in the previous article – here ive decided to gather all 3 enquiries for determination of currently loaded module, controller and action names. 1) Current Module name: $request = Mage::app()->getRequest(); $request->getModuleName(); 2) Current Controller name: $request = Mage::app()->getRequest(); $request->getControllerName(); 3) Current Action name: $request = Mage::app()->getRequest();; $request->getActionName(); SyntaxHighlighter.defaults['toolbar'] = false;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.all();if (window.jstiming) [...]

Read full story Comments { 0 }
Getting grand total values on cart, checkout and success pages

Getting grand total values on cart, checkout and success pages

Ive decided to combine different methods for different pages of the buying process in one article here. 1) Shopping Cart page: $grandTotal = Mage::getModel(‘checkout/cart’)->getQuote()->getGrandTotal(); 2) Checkout page: $grandTotal = Mage::helper(‘checkout’)->getQuote()->getBaseGrandTotal(); 3) Sucess page: $order = Mage::getModel(‘sales/order’)->loadByIncrementId(Mage::getSingleton(‘checkout/session’)->getLastRealOrderId()); $grandTotal = $order->getGrandTotal(); SyntaxHighlighter.defaults['toolbar'] = false;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.all();if (window.jstiming) window.jstiming.load.tick(‘widgetJsBefore’);if (typeof(BLOG_attachCsiOnload) != ‘undefined’ && BLOG_attachCsiOnload != null) { window['blogger_templates_experiment_id'] [...]

Read full story Comments { 0 }
How to control configs of other modules via your system.xml

How to control configs of other modules via your system.xml

All you need to do is just set and do all the necessary routine in it just like in the sample codes below: Enable some option select modulename/path_to_your_model adminhtml/system_config_source_yesno 1 1 1 1 class Your_class extends Mage_Core_Model_Config_Data { protected function _beforeSave() { $postData = Mage::app()->getRequest()->getPost(); $value = $postData['groups']['general']['fields']['somefield']['value']; Mage::getModel(‘core/config’)->saveConfig(‘wishlist/general/active’, $value); return $this; } } As [...]

Read full story Comments { 0 }
Getting Breadcrumb Path in Magento

Getting Breadcrumb Path in Magento

The most recent code i worked on – it gets current breadcrumb path and getting it prepared for further processing. I think everything is self-explanatory: $path = Mage::helper(‘catalog’)->getBreadcrumbPath(); foreach ($path as $name => $breadcrumb) { $breadcrumbs[$name][] = $breadcrumb['label']; $breadcrumbs[$name][] = $breadcrumb['link']; } SyntaxHighlighter.defaults['toolbar'] = false;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.all();if (window.jstiming) window.jstiming.load.tick(‘widgetJsBefore’);if (typeof(BLOG_attachCsiOnload) != ‘undefined’ && BLOG_attachCsiOnload != [...]

Read full story Comments { 0 }
Practical usage of label fields in Magento’s system.xml

Practical usage of label fields in Magento’s system.xml

I’ve discovered this “trick” when i was just beginning to work with Magento’s framework. I was think about a way to just show some info, which means no inputs but just raw text. Then ive come up with whis piece of code: Display in CMS pages label Ok, this is clear that label is for [...]

Read full story Comments { 0 }
Working with attributes in Magento

Working with attributes in Magento

Ive decided to share some usefull code in this post – which can be pretty usefull for the backend development. Ive created it in my spare time when been learning soap interface in Magento. This is gonna be a set of 3 functions(methods). 1st one called “getAttributeSetsThatContain” and made to get attribute sets which contain [...]

Read full story Comments { 0 }
How to quickly get all images of the product in Magento

How to quickly get all images of the product in Magento

If you want to get all images of the given product, then you should do this(code is good to be used anywhere – blocks, template, helpers, controllers): $gallery = Mage::getModel(‘catalog/product’)->load($product->getId())->getMediaGalleryImages(); $image_urls = array(); foreach ($gallery as $image ) { $imageUrls[] = Mage::helper(‘catalog/image’)->init($product, ‘image’, $image->getFile()); } SyntaxHighlighter.defaults['toolbar'] = false;SyntaxHighlighter.config.bloggerMode = true;SyntaxHighlighter.all();if (window.jstiming) window.jstiming.load.tick(‘widgetJsBefore’);if (typeof(BLOG_attachCsiOnload) != ‘undefined’ [...]

Read full story Comments { 0 }