Jul 30, 2014

What is Magento's skeleton and architecture

Magento is one of the most powerful E-Commerce PHP framework. Magento is very user friedly and easy to manage products, categories and sales orders etc. by administrator but vice versa for newbie developers, if you are just came in the wolrd of Magento and you are new born PHP developer then you will going to face lot of the problems to understand the Magento and it's architecture. It is like when you got the admission in 1st standard and learning Alphbets and Numbers... But what if someone makes all those things to learn and understand easily then no one can stop us to achive our target.

Don't worry guys... We have someone to help us.

You can visit my friend's blog to understand the Magento architecture easily. Click on below link.

http://kamleshkamble.blogspot.in/2014/05/magento-design-patterns.html

Jul 29, 2014

How to integrate FirePHP console logger in PHP

FirePHP is the Console Message Logger useful for ajax functionality to debug error and warning or information in browser console. This is the one of the most useful tool for the PHP developer to debug the issue or functionality. My friend Rajesh did this job for us very beautifully and with easy steps.

You can see how to install FirePHP by visiting my friend's blog below.

http://rajeshganjeer.wordpress.com/2014/07/18/firephp-the-console-message-logger-useful-for-ajax/

Thanks to Rajesh Ganjir for useful information shared.  

Jul 23, 2014

How to write, read and delete text file on Amazon S3 Buckets using zend framework

Write sample.txt File:

 
      
require_once "./library/Zend/Service/Amazon/S3.php";



$s3 = new Zend_Service_Amazon_S3($awsKey, $awsSecret);



$perms = array(

 Zend_Service_Amazon_S3::S3_ACL_HEADER =>

  Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ

);

try

{

 //writing content to sample.txt file

 $ret = $s3->putObject(

  $bucketName . '/sample.txt',

  'Sample text content',

  $perms

 );

}

catch (Exception $e)

{

 echo $e->getMessage();          

} 

Read sample.txt file data from s3 bucket:

 
      
try

{ //read txt_content from txt file      

 $txt_content = $s3->getObject($bucketName . '/sample.txt');    

}

catch (Exception $e)

{

 echo $e->getMessage();

}

Delete text file:


try

{

 $ret = $s3->removeObject($bucketName. "/sample.txt");

}

catch (Exception $e)

{

 echo $e->getMessage();

}

Jul 9, 2014

How to create admin Custom System Configuration Textarea field with wysiwyg editor enabled in Magento

We are going to create a custom module for above functionality, follows the below steps one by one.

Declaration: 
Namespace Name: Pg
Module Name: Adminconfigeditor

Step1: Create Pg_Adminconfigeditor.xml file and add in below path: app\etc\modules

 
      
<?xml version="1.0"?>

<config>

    <modules>

        <Pg_Adminconfigeditor>

            <active>true</active>

            <codePool>local</codePool>

        </Pg_Adminconfigeditor>

    </modules>

</config>


      

 


Step2: Create IndexController.php file and add in below path: app\code\local\Pg\Adminconfigeditor\controllers

 
      
<?php



class Pg_Adminconfigeditor_IndexController extends Mage_Core_Controller_Front_Action {



    public function indexAction() {

  

    }



}


      

 


Step3: Create Editor.php file and add in below path: app\code\local\Pg\Adminconfigeditor\Block\Adminhtml\System\Config\Editor.php

 
      
<?php

 class Pg_Adminconfigeditor_Block_Adminhtml_System_Config_Editor

    extends Mage_Adminhtml_Block_System_Config_Form_Field

    implements Varien_Data_Form_Element_Renderer_Interface {



 protected function _prepareLayout() {

   parent::_prepareLayout();

   if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {

    $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);

   }

 }

    protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {

        $element->setWysiwyg(true);

        $element->setConfig(Mage::getSingleton('cms/wysiwyg_config')->getConfig());

        return parent::_getElementHtml($element);

    }

}


      

 


Step4: Create Data.php file and add in below path: app\code\local\Pg\Adminconfigeditor\Helper\Data.php

 
      
<?php

class Pg_Adminconfigeditor_Helper_Data extends Mage_Core_Helper_Abstract

{

}

      

 


Step5: Create config.xml file and add in below path: app\code\local\Pg\Adminconfigeditor\etc\config.xml

 
      
<?xml version="1.0"?>

<config>

    <modules>

        <Pg_Adminconfigeditor>

            <version>0.1.0</version>

        </Pg_Adminconfigeditor>

    </modules>

    <frontend>  

        <routers>

            <adminconfigeditor>

                <use>standard</use>

                <args>

                    <module>Pg_Adminconfigeditor</module>

                    <frontName>adminconfigeditor</frontName>

                </args>

            </adminconfigeditor>

        </routers>       

    </frontend>

    <global>               

        <blocks>

            <adminconfigeditor>

                <class>Pg_Adminconfigeditor_Block</class>

            </adminconfigeditor>

        </blocks>

        <helpers>

            <adminconfigeditor>

                <class>Pg_Adminconfigeditor_Helper</class>

            </adminconfigeditor>         

        </helpers>           

    </global>

 <adminhtml>

  <acl>

   <resources>

    <all>

     <title>Allow Everything</title>

    </all>

    <admin>

     <children>

      <system>

       <children>

        <config>

         <children>

          <pg_section>

           <title>PG - All</title>

          </pg_section>

         </children>

        </config>

       </children>

      </system>

     </children>

    </admin>

   </resources>

  </acl>

 </adminhtml>   

</config>

      

 


Step6: Create system.xml file and add in below path: app\code\local\Pg\Adminconfigeditor\etc\system.xml

 
      
<?xml version="1.0" encoding="UTF-8"?>

<config>

    <tabs>

        <pg translate="label" module="adminconfigeditor">

            <label>Pg Admin Config Editor</label>

            <sort_order>100</sort_order>

        </pg>

    </tabs>

    <sections>

        <pg_section translate="label" module="adminconfigeditor">

            <label>Extension Options</label>

            <tab>pg</tab>

            <sort_order>1000</sort_order>

            <show_in_default>1</show_in_default>

            <show_in_website>1</show_in_website>

            <show_in_store>1</show_in_store>

            <groups>

                <pg_group translate="label" module="adminconfigeditor">

                    <label>My Extension Options</label>

                    <frontend_type>text</frontend_type>

                    <sort_order>1000</sort_order>

                    <show_in_default>1</show_in_default>

                    <show_in_website>1</show_in_website>

                    <show_in_store>1</show_in_store>

                    <fields>

                        <pg_input translate="label">

                            <label>My Input Field: </label>

                            <comment>My Comment</comment>

                            <frontend_type>text</frontend_type>

                            <sort_order>20</sort_order>

                            <show_in_default>1</show_in_default>

                            <show_in_website>1</show_in_website>

                            <show_in_store>1</show_in_store>

                        </pg_input>

                        <pg_select translate="label">

                            <label>My Dropdown: </label>

                            <comment>Test Comment</comment>

                            <frontend_type>select</frontend_type>

                            <sort_order>90</sort_order>

                            <show_in_default>1</show_in_default>

                            <show_in_website>1</show_in_website>

                            <show_in_store>1</show_in_store>

                            <source_model>adminhtml/system_config_source_yesno</source_model>

                        </pg_select>

      <pg_textarea_wysiwyg>

          <label>Wysiwyg Textarea Example</label>

          <frontend_type>editor</frontend_type>

          <frontend_model>adminconfigeditor/adminhtml_system_config_editor</frontend_model>

          <sort_order>120</sort_order>

          <show_in_default>1</show_in_default>

          <show_in_website>1</show_in_website>

          <show_in_store>1</show_in_store>

          <comment>Textarea field with wysiwyg editor enabled.</comment>

      </pg_textarea_wysiwyg>

                    </fields>

                </pg_group>

            </groups>

        </pg_section>

    </sections>

</config>


      

 


Step7: Done. Go to admin system configuration, you should see the below screen. Note: Clear cache and make sure you have enabled wysiwyg setting from admin -> system->config->content management.