1

I was working with PHP Core and custom MVCs by 1 and half years until when moved to magento desk.

I find it very difficult first, but later got grip in Theme integration and maintenance of previously done modules. Now I got in to Module creation and really confused with the architecture.

In frank, Everytime when I write a new code, It works well, but later edited out wasting so much time of seniors since It does not met completely with Magento's coding style.

For an example, when I need to check something and update a database, I writes,

<?php 
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = "SELECT ststus FROM table WHERE Id='".$id."'";
$select_query = $readConnection->fetchOne($query);
$update_value= $select_query[0];
if($update_value=='2')
{
$writeConnection = $resource->getConnection('core_write');
$query = "UPDATE table SET field_name='C' WHERE Id='".$id."'";
$writeConnection->query($query);
}
?>

This is later changed to simply this,

foreach ($dealroomIds as $dealroomId) {
                $manufacturers = Mage::getSingleton('module/module')
                    ->load($dealroomId)
                    ->setStatus($this->getRequest()->getParam('status')); //getting status 
                    if($this->getRequest()->getParam('status')=='2'){
                    $manufacturers->setRunningStatus('C'); // setting new status
                    }
                $manufacturers->setIsMassupdate(true)
                    ->save();
                Mage::getSingleton('dealroom/deals')->UpdateDealProducts($dealroomId); // Update
                    }

The above given is just an example and nothing more than that.

To know more about the coding style and standard, I think is neccessory to know more about

  • Block
  • controllers
  • Model
  • Helper
  • Data

I searched but whatever I read and understand is just far away from the basic. If anyone point out the connections and functions of these, it will be helpful to me.

Rick Kuipers
  • 4,260
  • 2
  • 20
  • 24
Vishnu R
  • 597
  • 1
  • 6
  • 21

3 Answers3

4

Best practice? http://www.alanstorm.com, great blog that explains all the basics. I learned Magento this way :). Take a look at the creation of backend and frontend extensions!

Toon Van Dooren
  • 1,049
  • 8
  • 25
3

A good start would be Magento Developer Knowledge base articles Then as mentioned, read Alan Storm's articles and watch Fundamentals of Magento Development Video Course by Magento (Ben Marks)

After that, I think, you should have a look at official Extension's Developer Guide by Magento - 80 pages on how-to create a custom extension (News) from scratch

Sergei Guk
  • 2,182
  • 2
  • 17
  • 18
2

There are tons of useful and well written guide to create and understand module architecute.

Just to name a few :

http://coding.smashingmagazine.com/2012/03/01/basics-creating-magento-module/

http://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/

Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69
dagfr
  • 51
  • 2