Need help buying now? +48-22-219-5163 +1-917-720-3250
My Cart

Your Cart is Empty

Need help buying now?
+48-22-219-5163 +1-917-720-3250

Tips For Novice Magento Developers

Tips For Novice Magento Developers

Nowadays you are able to find any necessary information regarding the site configuration, but most often the simplest questions are left without the answer. Here are some tips for novice Magento developers: how to create a new item in the admin menu, how to look through SQL collections and how to output the widget.

How to create a new item in the admin menu

In order to create a new item in the top Magento admin menu you need to do the following:

You need to create a new file called adminhtml.xml in the etc folder in the store extension which is responsible for the top menu. You should insert the code which is written below in this file:


<?xml version="1.0"?>
<config>
  <menu>
      <df_test translate="title" module="df_test">
           <title> The name of the menu item </title>
           <sort_order>71</sort_order>
          <children>
              <action1 translate="title" module="df_test">
                  <title> subparagraph 1</title>
                   <action>adminhtml/action1</action>
                   <sort_order>10</sort_order>
               </action1>
              <action2 translate="title" module="df_test">
                   <title> subparagraph 2</title>
                   <action>adminhtml/action2</action>
                   <sort_order>20</sort_order>
               </action2>
          </children>
      </df_test>
  </menu>
  <acl>
      <resources>
          <admin>
               <children>
                   <df_test translate="title" module="df_test">
                       <title> your name of the menu item </title>
                       <children>
                          <action1 translate="title" module="df_test">
                               <title> subparagraph 1</title>
                               <sort_order>10</sort_order>
                           </action1>
                           <action2 translate="title" module="df_test">
                               <title> subparagraph 2</title>
                               <sort_order>20</sort_order>
                           </action2>
                       </children>
                  </df_test>
               </children>
          </admin>
      </resources>
  </acl>
</config>

 

After this you should save the changes and check the existence of the updated menu structure. If the item does not appear, you need to disable the cache and check one more time. Also you may have some difficulties. It depends on the extension you want to install. The issue may be in this extension.

How to hide products from the showcase

In some cases you need to hide the commodity positions from the showcase (the store block which is visible for customers). There are not any difficulties. You need to correct the code. In order to do it you should go to the admin store part and write the following code in the editor:


* @var int $productId
* Identification number of a particular commodity
*/
$productId = 888;
/** @var Mage_Core_Model_Store $currentStore  */
$currentStore = Mage::app()->getStore();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
try {
	Mage::getModel ('catalog/product')
   	->load ($productId)
   	->setData ('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VI
    SIBLE)
   	->save ()
	;
}
catch (Exception $e) {
	/**
	* fix bugs
	*/
}
Mage::app()->setCurrentStore($currentStore);

 

You should save the changes and check the work again.

The easiest question from the listed ones in the beginning of the article is how to output SQL collections:


/** @var Varien_Data_Collection_Db $collection */
$collection
   	->printLogQuery(
           	false   // show SQL on the screen
           	,
               true	// note SQL in log messages	
   	)
;

 

In order to output programmatically a social or payment widget in your Magento store you need to write down the following code in the editor:


echo
	Mage::getModel ("widget/template_filter")
   	->filter(
       	'Magento Development and Magento Integration from Magento Experts
'
   	)
;

 

In order to list all the new products you will need the following code:


$collection =
       Mage::getResourceModel('catalog/product_collection')
           	->addAttributeToSelect('*')
           	->addStoreFilter()
           	->addAttributeToFilter(
                   	'status'
                   	,
            	       array ('in' => Mage::getSingleton('catalog/product_status')->get
                     VisibleStatusIds())
           	)           	
           	->setOrder('created_at', 'desc')            	
;
$collection->getSelect()->limit (3);
$collection->load ();

 

The recipe of the code has been taken from the site magento-forum.ru

If you have any problems, you can contact our GoMage Team and they will help you to solve any issues connected with your Magento store.

Newsletter