/   /   /  OroCommerce for Developer: Customer User and Preferred Localization

Note:

For more extensions and themes visit our store

OroCommerce for Developer: Customer User and Preferred Localization


So OroCommerce offer ability to define which Preferred Localization for specific Customer User with filed Preferred Localization Your can choose between all locale added from configuration. The field  Preferred Localization get showed just if you’re choosing more than one locale from configuration.
let’s add other locale go System→Configuration → System Configuration (Section) → localization:
From Enabled Localizations add one other language like Germany .

The filed has added to Edit customer user and view in section general ,  the form extension has used:
to show in edit and view the service :

  1.  
  2.     oro_customer.form.extension.preferred_localization_customer_user:
  3.         class: Oro\Bundle\CustomerBundle\Form\Extension\PreferredLocalizationCustomerUserExtension
  4.         arguments:
  5.             - '@oro_customer.form.event_listener.preferred_localization_customer_user'
  6.         tags:
  7. - { name: form.type_extension, extended_type: Oro\Bundle\CustomerBundle\Form\Type\CustomerUserType }
  8.  

Explore  Oro\Bundle\CustomerBundle\Form\Extension\PreferredLocalizationCustomerUserExtension for more info .

Note: the page customer edit and view has just 2 block with name 0 and one you can show all blocks of admin of specif route by :

  1.  
  2.         $scrollData = $event->getScrollData();
  3.         var_dump($scrollData->getBlockIds());die();
  4.  

the scrollData is instance of Oro\Bundle\UIBundle\View\$scrollData; 

To save  Preferred Localization the service which used is – EventListener -:

  1.  
  2.     oro_customer.form.event_listener.preferred_localization_customer_user:
  3.         class: Oro\Bundle\CustomerBundle\Form\EventListener\PreferredLocalizationCustomerUserSubscriber
  4.         arguments:
  5.             - '@oro_website.manager'
  6.             - '@oro_config.manager'
  7.             - '@doctrine'
  8.  

Explore 2 functions of class PreferredLocalizationCustomerUserSubscriber
1 - onPostSetData
2 - onPostSubmit

The table which register all info related to  Preferred Localization is oro_customer_user_settings
the Entity is CustomerUserSettings

and has relation OneToMany  with CustomerUser as:

  1.  
  2.     /**
  3.      * @var ArrayCollection|CustomerUserSettings[]
  4.      *
  5.      * @ORM\OneToMany(
  6.      *      targetEntity="Oro\Bundle\CustomerBundle\Entity\CustomerUserSettings",
  7.      *      mappedBy="customerUser",
  8.      *      cascade={"all"},
  9.      *      orphanRemoval=true
  10.      * )
  11.      * @ConfigField(
  12.      *      defaultValues={
  13.      *          "importexport"={
  14.      *              "excluded"=true
  15.      *          }
  16.      *      }
  17.      * )
  18.      */
  19.     protected $settings;
  20.  

So you can make lot of customization based on Preferred Localization.

Comments

Related Posts

make your store more efficient

Solving problems. With open source technology. Professional results. That’s what makes Ibnab your best choice

IBNAB is a company made of a group of professionals whose work is providing secure open source solutions. Our company strives for reaching magnificent results with each experience and provides professional open source solutions that cover every part of the business process.