Overview

 M2E Pro allows observing data changes triggered by various Magento Core Models. However, very frequently: Magento Products, Categories, Attributes, etc. are updated without usage of Magento Core Standard Functionality (Magento Core Models), so M2E Pro may not detect these changes.

M2E Pro may not detect changes if:

  • Data is manipulated via direct SQL requests (Direct SQL injections);
  • Changes made by side models of a side module;
  • Changes made through Magento API;
  • Any other approach that is not using a Magento Core Functionality.

If data in your Magento system gets updated by any of the above-described methods, there is a requirement to notify M2E Pro explicitly. There are 2 options to do that:

  1. Object method - uses all variations of M2E Pro (slower);

  2. Structural model- only tracks data changes in existing Magento Products (fast);

These models can be found in your Magento File system in the following path: app/code/community/Ess/M2ePro/Model/PublicServices.

Object method

Object method notifies M2E Pro about all Magento Product changes and facilities:

  1. automated addition/removal of products from M2E Pro Listings (Auto Add/Remove Rules);

  2. synchronization (List, Relist, Stop and all available options of Revise Rules);

  3. tracking of changes in all attributes used in Magento product settings.

Usage of Object Model(sample):

$model = Mage::getModel('M2ePro/PublicServices_Product_ObjectChange');

// you pass a product ID for observing

$model->observeProduct(561);

// you have 'catalog/product' object for observing

$product = Mage::getModel('catalog/product')

->setStoreId(2)

->load(562);

$model->observeProduct($product);

// make changes for these products by direct sql

$model->applyChanges();
CODE

A snippet of the code above demonstrates the creation of an M2E Pro Object Model. Then 2 products are registered and changes to these products are observed in 2 different ways. Once products have been registered, data for these products can be manipulated using SQL injections or any other method.

After data is changed, the method applyChanges() must be called. While method applyChanges() is running, M2E Pro will automatically observe all the changes that have originated outside of Magento Core Models.

Recommendations

For multiple Magento product data change:

  1. create M2E Pro Object Model

  2. register in products to be updated Products

  3. apply changes

  4. trigger method applyChanges()

We do not recommend (!) creating individual M2E Pro Object Models for each product.

Also, the Object Method is not suitable for a large number of product changes (i.e. in 10.000’s) because Object Method is very resource-consuming. It observes all automatic features of M2E Pro and slows down your code execution making import/update tools (if any) to work at unsatisfactory speed.

Structural model

Structural Model notifies M2E Pro about changes made to a particular attribute/option (only price, quantity, status) of a Magento Product. This model is different from the Object method:

  • Object Method catches changes from the moment of registration to the moment of execution

  • Structural Method requires only notification confirming changes of a particular product data

Structural Method triggers some of an M2E Pro automation features (List, Relist, Stop Rules of Synchronization Policy and Price/Quantity Revise Rules). All other features will not work if Structural model is used.

Usage of the Structural Model (sample):

$model = Mage::getModel('M2ePro/PublicServices_Product_SqlChange');

// notify M2E Pro about changes in price, qty or status in the product with ID 17

$model->markProductChanged(17);

// make price change to the product with ID 18 and then notify M2E Pro

$model->markPriceWasChanged(18);

// make QTY change to the product with ID 19 and then notify M2E Pro

$model->markQtyWasChanged(19);

// make status change to the product with ID 20 and then notify M2E Pro

$model->markStatusWasChanged(20);

$model->applyChanges();
CODE

A snippet of the code above demonstrates the usage of an M2E Pro Structural Model in respect to Price, QTY, Status changes.

Note

Please be advised that the markProductAttributeChanged method is no longer supported.

Recommendations

M2E Pro Structural Model usage:

  1. create an instance of M2E Pro Structural model

  2. make changes to Magento Products data (i.e. direct SQL requests)

  3. reflect these changes in the model

  4. trigger method applyChanges() of the structural model

We do not recommend (!) creating an individual M2E Pro Pro Structural model for each product.

Also, always utilize the Structural model for a high number of Magento products’ changes. This method works fast (vs Object method) and not resource-consuming. We do not recommend using this method if your system is making use of all automatic features of M2E Pro.