Magento 2 - Customized Data

If your store implemented some unique functionality that modifies customer, order or product data, and you want to make sure Remarkety uses the custom data instead of Magento's built-in fields, you can extend Remarkety's Magento 2 plugin using a custom Magento plugin that modifies the data before it is passed to our system.

For overriding the data, you will need to have installed version 2.3.1 or above of our Magento 2 plugin, as well as your custom "override plugin".

To create the override plugin, download a sample here, customize the code, and then install it.

You will want to specifically modify the /Remarkety/CustomOverride/DataOverride.php file.

This file extends the DataOverride class from Remarkety's plugin, and it can override the following 5 methods: customer, newsletter, cart, order, product.

Sample - override product URL and image

Add the following method to the DataOverride class:

/**
* @param ProductInterface $product
* @param $data
* @return mixed
*/
public function product($product, $data){
$data['url'] = customUrlMethod();
$data['image'] = [
'src' => customImageMethod()
];
$data['images'] = [
[
'src' => customImageMethod()
]
];
return $data;
}

You will need to write your custom logic for getting the custom url and custom image (in this sample)

Installing the override plugin

To install the new plugin please follow these steps:

  1. Ugrade Remarkety's plugin to the latest version (at least 2.3.1)
  2. Upload the customized plugin ZIP to <Magento2 Root>/app/code
    You should now have a folder at <Magento2 Root>/app/code/Remarkety/CustomOverride
  3. Run the following commands to install the new plugin:
    • bin/magento setup:upgrade
    • bin/magento cache:clean
    • bin/magento setup:di:compile
Have more questions? Submit a request

0 Comments

Article is closed for comments.