Search This Blog

Tuesday, May 8, 2012

Facebook PHP login logout working code

define('FACEBOOK_APP_ID', '***YOUR FACEBOOK APPLICATION ID HERE***');
define('FACEBOOK_SECRET', '***YOUR FACEBOOK SECRET APPS KEY HERE***');
function get_facebook_cookie($app_id, $application_secret) {
  $args = array();
  parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
  ksort($args);
  $payload = '';
  foreach ($args as $key => $value) {
    if ($key != 'sig') {
      $payload .= $key . '=' . $value;
    }
  }
  if (md5($payload . $application_secret) != $args['sig']) {
    return null;
  }
  return $args;
}
$cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<?php if ($cookie) {
//cookie is set, user is logged in
$user = json_decode(file_get_contents('https://graph.facebook.com/'.$cookie['uid']));
//Display the facebook user ID, name, gender and Facebook URL in the web browser
echo '<br />';
echo 'Your Facebook ID: '.$user->{'id'};
echo '<br />';
echo 'Your name: '.$user->{'name'};
echo '<br />';
echo 'Your gender: '.$user->{'gender'};
echo '<br />';
echo 'Your Facebook URL: '.$user->{'link'};
echo '<br />';
echo '<fb:login-button autologoutlink="true"></fb:login-button>';
}
else
{
//user is not logged in, display the Facebook login button
echo '<h2>Facebook Application Test page</h2>';
echo '<br />';
echo 'This is the most basic Facebook application PHP source code that will grab the user Facebook full name, gender and Facebook URL.';
echo '<br />Then displays those information in the web browser once the user has successfully logged in';
echo '<br /><br />';
echo '<fb:login-button autologoutlink="true"></fb:login-button>';
}
?>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({appId: '<?= FACEBOOK_APP_ID ?>', status: true,
cookie: true, xfbml: true});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
</script>
</body>
</html>

Monday, May 7, 2012

Magento Developer Certification

Few days ago Magento announced their plans for Magento certification program. As they stated, initial round of certification will be a Beta exam, held on Innovate Developer Conference in San Francisco, October 12 and 13! Those who pass the exam based on the Beta exam analysis, will actually earn the official Magento Developer certification. Final reward for those who pass the exam? They will receive Magento certificate and be able to use the official logo with their name and title. Clearly there is more to it than just a piece of paper, so let me share my thoughts and views with you.

The thing about the certification is that it’s not only about the piece of paper or a card issued by some authority verifying your knowledge and expertise. If you look at it more deeply, additional value lies in the individuals desire to actually go trough it. This shows determination and love towards an area of interest. It’s hard to imagine someone would go trough all the hassle of certification as specific as this one if he does not love his work. This goes for certification in general, not just Magento. This is something hiring managers will know how to recognise and value.

From a personal point of view, as a developer you gain recognition of your Magento skills. Which is not to be ignored, as Magento still is one of the most robust eCommerce platforms our there. This can help differentiate yourself from the competition, possibly increase your value on the market. Not to mention there is a good chance you gain some additional knowledge through preparation and training. Face it as much as you know Magento chances are you skipped a “chapter or two” in your everyday real job (I know I did).

On a company level, there is also a bonus of having some or all of your developers certified. This usually goes in favour of your overall quality.

I’m sure most of you in Magento business will agree that Magento certification was more than welcome and I would even say needed. With all their great products and services now available time is right for quality certification program. I’m only hoping that over the next few months, year or two, most of us in everyday Magento development will earn ourselves a certificate :)

So what’s it all about? Magento Developer Certification landing page has a nice little PDF file called Certified Developer Exam: Self Assessment Checklist. It outlines the certification program which comprises of two levels:

    Magento Certified Developer (MCD)
    Magento Certified Developer Plus (MCD Plus), has an additional 20 questions

Questions are based on Magento Community Edition Magento Enterprise Edition. Surprisingly there is a detailed outline of 10 specific areas that exam covers, all you need to do is to study it.

    Basics (5%)
    Request Flow (7%)
    Rendering (8%)
    Working with Database in Magento (12%)
    Entity-Attribute-Value (EAV) Model (10%)
    Adminhtml (8%)
    Catalog (10%)
    Checkout (15%)
    Sales and Customers (12%)
    Advanced features (13%)

Check the document for details.

In a nutshell that’s it for now. Grab your Magento installations, some coffee, and run trough outlined exam areas if you are interested in taking exam. I must say, it does not look like it’s going to be easy. Regardless of your experience, Magento is still a large platform, meaning lot of terrain to cover so get prepared:)

Cheers.

Source http://inchoo.net/ecommerce/magento/magento-certification-why-bother/

More links and study guide

http://www.magentocommerce.com/blog/magento-developer-certification-how-do-i-know-if-im-ready/
 

Friday, May 4, 2012

Grouped Vs Bundle Products

Grouped Products

A grouped product is essentially a selection of simple products displayed equally on the product page, each with quantity boxes so the user can decide how many of each they want before they add to cart.The products displayed are normally of a similar nature (e.g. a plate and a saucer)

Examples
  
  • Tablewewar Set - Imagine a product called ‘tablewear set’, and you can decide how many plates, dishes, cups and saucers you want to buy as part of the set.
  • Box of Pens – Similar to the tablewear set, another example of a grouped product may be for purchasing pens for a company. A grouped product is great for when you need to buy in bulk. The product may be Biro pens, and you can decide how many of your biro pens are red, blue, green and black.
  • Set of Knives – This is an example used on Magento’s own website and nicely demonstrates a grouped product in all its glory. You can purchase a set of Chef’s knives and you can decide how many of each size you want in the set.
 

Bundle Products

A bundle product should viewed as a product you get to customise to your requirements. You choose what goes with it and how high/low spec you want it to be. This gives customers the freedom to pretty much ‘build’ their ideal product. The products displayed are normally not very similar (e.g. a hard drive and a mouse mat).
 
Examples
  •     Tennis Racket – The name and make of the tennis racket is the bundle product, but you have to build your racket as a bundle. So you choose the grip size, followed by the strings you want. A nice custom option box could be thrown in to determine the tension of the strings. You can also throw in a racket bag and extra grips if you wish.
  •     Build your Computer – This is the most famous bundle product on Magento’s Demo Store. When you build your computer you can customise everything including what size processor you want, which monitor you want, the inclusion of extra graphics card etc, until you have

 

Monday, April 30, 2012

Magento admin grid add from and to search in admin grid

Magento admin grid add from and to search in admin grid

$this->addColumn("designer_id", array(
                "header" => Mage::helper("Module")->__("User ID"),
                "align" =>"right",
                "width" => "50px",
                'type'  => 'currency',
                "index" => "user_id",
                ));

                'type'  => 'currency', is used to search for integer or decimal type

$this->addColumn("created_date", array(
                "header" => Mage::helper("Module")->__("Modified Date"),
                "align" =>"center",
                "width" => "100px",
                'type' => 'datetime',
                "index" => "mod_date",
                ));

                'type' => 'datetime', is ued to seach date time range

Thursday, April 26, 2012

Magento admin grid mass delete, mass status change checkbox option

Magento admin grid mass delete, mass status change checkbox option

In your Grid.php add
protected function _prepareMassaction()
    {
        $this->setMassactionIdField('Module_id');
        $this->getMassactionBlock()->setFormFieldName('banners');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('Module')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('Module')->__('Are you sure?')
        ));

        $statuses = Mage::getSingleton('Module/status')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
             'label'=> Mage::helper('Module')->__('Change status'),
             'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             'additional' => array(
                    'visibility' => array(
                         'name' => 'status',
                         'type' => 'select',
                         'class' => 'required-entry',
                         'label' => Mage::helper('Module')->__('Status'),
                         'values' => $statuses
                     )
             )
        ));
        return $this;
    }
-----------------------------------------------------------
in your adminhtml-> XXXcontroller .php file
 public function massDeleteAction() {
        $ids = $this->getRequest()->getParam('Module');
        if(!is_array($ids)) {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Banner(s)'));
        } else {
            try {
                foreach ($ids as $id) {
                    $banners = Mage::getModel('Module/Module')->load($id);
                    $banners->delete();
                }
                Mage::getSingleton('adminhtml/session')->addSuccess(
                    Mage::helper('adminhtml')->__(
                        'Total of %d record(s) were successfully deleted', count($ids)
                    )
                );
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            }
        }
        $this->_redirect('*/*/index');
    }
   
    public function massStatusAction()
    {
        $bannersIds = $this->getRequest()->getParam('module');
        if(!is_array($ids)) {
            Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Banner(s)'));
        } else {
            try {
                foreach ($ids as $id) {
                    $banners = Mage::getSingleton('Module/Module')
                        ->load($id)
                        ->setStatus($this->getRequest()->getParam('status'))
                        ->setIsMassupdate(true)
                        ->save();
                }
                $this->_getSession()->addSuccess(
                    $this->__('Total of %d record(s) were successfully updated', count($ids))
                );
            } catch (Exception $e) {
                $this->_getSession()->addError($e->getMessage());
            }
        }
        $this->_redirect('*/*/index');
    }

Magento in admin html backend add a coloumn Action

Magento in admin html backend add a coloumn Action

magento add action coloumn in admin  grid

Code

$this->addColumn('action',
                        array(
                            'header'    =>  Mage::helper('Module')->__('Action'),
                            'width'     => '100',
                            'type'      => 'action',
                            'getter'    => 'getId',
                            'actions'   => array(
                                array(
                                    'caption'   => Mage::helper('Module')->__('Edit'),
                                    'url'       => array('base'=> '*/*/edit'),
                                    'field'     => 'id'
                                )
                            ),
                            'filter'    => false,
                            'sortable'  => false,
                            'index'     => 'stores',
                            'is_system' => true,
                    ));