Engine23

Development

Magento 1.8 Event Observer List

app/code/core//Mage/Admin/Model/Session.php: Mage::dispatchEvent('admin_session_user_login_success', array('user' => $user));

app/code/core//Mage/Admin/Model/Session.php: Mage::dispatchEvent('admin_session_user_login_failed',

app/code/core//Mage/Admin/Model/User.php: Mage::dispatchEvent('admin_user_authenticate_before', array(

app/code/core//Mage/Admin/Model/User.php: Mage::dispatchEvent('admin_user_authenticate_after', array(

Read more

Install GIT on Centos 5.7

Here is fast and easy way to install Git on Centos 5.7.

1. Get the EPEL release for Centos 5.

# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

2. Install git, git-daemon using yum

# yum install git git-daemon

Magento - How to get product collection ( 2 ways )

Version #1 use a simple array

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter('sku', array('n2610','bb8100'));


$items = $collection->getItems();
echo count($collection);

Version #2 use a more specific array

$collection = Mage::getModel('catalog/product')->getCollection();

$collection->addAttributeToFilter(
array(
array('attribute'=>'sku','eq'=>"n2610"),
array('attribute'=>'sku','eq'=>"bb8100")
));

$items = $collection->getItems();
echo count($collection);

Magento - Get the sql for a collection

If you ever were curious about what the SQL is being built for a Magento Collection, its really, really easy

$collection = Mage::getModel('poll/poll')->getResourceCollection()
->addFieldToFilter('date_posted', array('from' =>'2014-02-01 00:00:00', 'to'=>'2014-02-28 23:59:59'));
$collection->load(true);

The result will be something similar to this:

SELECT `main_table`.* FROM `poll` AS `main_table` WHERE (date_posted >= '2014-02-01 00:00:00' AND date_posted <= '2014-02-28 23:59:59')

Magento - How to fix error message: MediabrowserUtility is not defined

 error: error in [unknown object].fireEvent():

event name: open_browser_callback

error message: MediabrowserUtility is not defined 

Step 1: Add this to the adminhtml xml for the custom extension

<?xml version="1.0"?>
<layout>
<default>
<reference name="head">
<action method="setCanLoadExtJs"><flag>1</flag></action>
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
<action method="addJs"><script>lib/flex.js</script></action>
<action method="addJs"><script>lib/FABridge.js</script></action>
<action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
<action method="addJs"><script>mage/adminhtml/browser.js</script></action>
<action method="addJs"><script>prototype/window.js</script></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
</reference>
</default>
</layout>

Read more

Masterlock - combination recovery helper

One day, I was at work and a friend of mine was trying to recall what his Master lock combination was.  He knew the first and last number.  I had done a bit of googling and found that if you know the last number of the combination, there is a defined set of possible options!  This was promising.  After figuring out the algorythm, I set forth on a quest to provide a nice template for him to use when doing the recovery.  It turns out that there are only 100 possible combination should you know that last number. 

If you want to use it, please click here.

Magento - Concat part of a magento collection

When building admin area modules, you need to sometimes use the admin users. When doing so, you may want to combine the firstname and lastname into one. This is where concat comes in handy. It will combine them, into one string to be used as the visual for the dropdown. The following function will also show you how to get all the admin users using a collection.

    /*
    *  
    */
    public function getAdminUsersAsOptions()
    {

        $collection = Mage::getModel('admin/user')->getCollection()
                            ->addFieldToSelect('firstname')
                            ->addFieldToSelect('lastname')
                            ->addFieldToSelect('user_id');
        $collection->setOrder('lastname', 'ASC');
        $fields      = array('lastname', 'firstname');
        $fieldConcat = $collection->getConnection()->getConcatSql($fields, ', ');

        $collection->getSelect()->columns(array('value'=> 'user_id', 'name' => $fieldConcat));
        $items = $collection->getItems();
        $user_array = array();
        foreach($items as $_user)
        {
            $user_array[$_user->getData('user_id')] = $_user->getData('name');
        }
        return $user_array;
    }

Setting new Mac 10.9 for PHP development

  1. Download MySQL DMG  http://dev.mysql.com/downloads/mysql/
  2. Install both the MySQL and the startup packages ( this may require approval in your  Mac OS X Privacy & Security settings )
  3. Start mysql via command line  
    sudo /usr/local/mysql/support-files/mysql.server start
  4. Start apache via command line  
    sudo apachectl start
  5. Create a folder for your virtual host files
    sudo mkdir  /etc/apache2/extra/vhosts 

Read more