Gigya Job Openings

Advanced Events and Observers

Skip to end of metadata
Go to start of metadata

« Back to Gigya Extension for Magento 1.x

 

Overview

The Gigya extension generates events that can be used to extend or override the extension's functionality using Magento's observer methodology.

For an introduction to Magento events and observers, see the Magento documentation.

Events

The Gigya extension for Magento 1.x provides the following events.

Event NameParametersDescription

gigya_raas_pre_login

Event triggered before logging a user into the system through Gigya's RaaS.

gigya_raas_post_login

  • $customer_session (Magento customer session object)
  • $gigyaData (Gigya Account object)

Event triggered after logging a user into the system through Gigya's RaaS.

gigya_social_pre_login

  • $customer (Magento customer object)
  • $gigyaData (Gigya User object)

Event triggered before logging a user into the system through Gigya's Social Login.

gigya_social_post_login
  • $customer_session (Magento customer session object)
  • $gigyaData (Gigya User object)
Event triggered after logging a user into the system through Gigya's Social Login.
gigya_pre_user_create
  • $customer (Magento customer that is about to be created)
  • $gigyaData (Gigya Account object if created under RaaS, Gigya User object if created through Social Login)
Event triggered before creation of a new Magento customer, either in RaaS or through Social Login.

gigya_counter_pre_send

  • $counter (the counter object about to be sent to Gigya)

Event triggered before purchase data is sent to Gigya Customer Insights.

gigya_pre_review_reminder
 
Event triggered before sending a "need to review" reminder to a customer who has made a purchase.
gigya_pre_field_mapping

See Using Events and Observers for Advanced Field Mapping.

pre_sync_to_gigya

Creating an Event Observer

  1. Insert the following tags inside the ... tags of your config.xml file. The path to this file must be located according to Magento rules (in the folder /app/code/local/yournamespace/yourmodule/etc) :

    <events>
    <event_Name (one of the events listed in the table above)> 
        <observers>
        <observerName (a name for the observer)>
            <type>singleton</type>
            <class>className (name of the class that is to be loaded when the event fires)</class>
            <method>methodName (name of the method to be executed within the class)</method>        
        </observerName>
        </observers>
    </event_Name>
    </events>
    
  2. Create a class with the name you used in the config.xml tag and inside that class, create a method with the name you used in the config.xml tag (this is located in the folder: /app/code/local/yournamespace/yourmodule/Model).

    <?php
    class className
    {
        public function methodName($observer) {
            // Get customer object
            $customer = $observer->getCustomer();
            // Get gigya data
            $gigyaInfo = $observer->getGigyaData();
            // set info as required...         
        }
    } 
    ?>

Example: Changing the Price Field on the Signals Information Returned to Gigya

In the following example, we override the amount that is sent after purchase to Gigya's Signals (this is used in Customer Insights).

By default the Gigya extension sends the total price that customer pays (including taxes, shipping, etc.). In the following example we override the value to be the basic price that the stores receives ("base total paid"). 

The plugin registers for the gigya_counter_pre_send event in config.xml and causes the Magento event observer to call the method overridePurchaseValue in class gigya_Observer_Class in your Magento Model folder.

Config.xml:

<?xml version="1.0"?>
<config>
<global>
       <events>
          <gigya_counter_pre_send>
              <observers>
                  <gigya_observer>
                      <type>singleton</type>
                      <class>Gigya_Class</class>
                      <method>updated_counters</method>
                  </gigya_observer>
              </observers>
          </gigya_counter_pre_send>
       </events>
  </global>
</config> 

The following PHP code sets the purchase "base total paid" amount in the Gigya Counter object:

<?php 
class Gigya_Observer_Class {
    public function updated_counters($observer) {
        $counters = $observer->getCounter(); // Get Gigya counter
        $order = $observer->getOrder(); // Get Magento order object
        $counters->value = $order->getBaseTotalPaid(); // Override counter value and set it to "base total paid"
     }
} 
?>

 

Save