HOW IT OPERATES: Magento 2 Partial Indexed

Location: 230000

Date posted 12 Apr 2017

Price: $ 299

Ad ID: 146944

Reply by email

Anyone who has ever used Magento 1 or Magento 2 knows about such feature as index. It is quite important and useful since anything that is shown on the frontend relates to index. Indexing by itself is a pretty long process that is why partial index has been available almost because the first version of Magento. Incomplete index means that people index not the complete document but only the part that has been modified.

View more : https://www.magebay.com

In Magento 2 EE there are available 2 indexing modesUpdate on Save and Update by ScheduleYou could configure each function under Tools -> System -> Index Management. All of them has its advantages and disadvantages. The main good thing about the Update on Save mode is the fact that it enables you to index data after saving the reportIn other words, once you save something in a category it becomes instantly available on the frontend with all the changes as applied. However, the key disadvantage is that it incredibly increases the time for each operation to complete. That is why, to speed up the process there's been introduced the Update by Schedule method. This feature lets you index data in the background so there is absolutely no wait when you try to save any report. Everything is performed asynchronously. The sole minus of this method is that it could really take a while until the cron job starts indexing.

In this article we will describe how partial index works. Let`s say that our default function is Revise by Routine, so, if not suggested otherwise, the below explanation will concern exactly this technique.

There is no special devote the Magento code where you can find incomplete index entities worth. The whole logic of partial index is performed in a databases - via MySQL sets off if to become more specific. For example, the catalog_product_entity desk contains 3 triggers for the next occasions: AFTER INSERT, AFTER UPDATE, AFTER DELETE.

 

As seen from the above code the result in creates an archive in the *_cl dining tables in regards to a new entity. Let's check one particular *_cl tables. All of them are identical, so, what is true for one of them is also true for others. Each table is made up of 2 fields: version_id and entity_id. The version_id field reveals the current changes version quantityas the entity_id field shows the ids of the entities which need to be indexed.

When indexing is started by the cron job, the version_id ideals in the *_cl tables are compared to the files from the mview_condition table which contains the information about index variations and index positionIn the code side the reasoning is managed by the Mview module which is a part of the Magento framework.

The cron job calling the \Magento\Framework\Mview\View::update method that telephone calls the mandatory index. Let's take a look at this method somewhat closer:

 

For each index there is created a separate Mview class object that is in charge of index update.

View more : https://productsdesignerpro.com/

Let's see what the factors from the above code are a symbol of:

  • $currentVersionId - implies the existing version of the version_id field in the *_cl table;
  • $lastVersionId - is the previous version of the corresponding index, taken from the mview_point out table;
  • $ids - are the ids of the entities that need to be indexed.


From then on, each index becomes partially re-indexed in its own way. Now let's see if it is possible to add custom causes to MySQL furniture and perform custom incomplete indexing. Let's check the \Magento\Framework\Mview\View::subscribe method:

The first range verifies whether incomplete indexing is allowed for the Mview index. Next, there is created a individual *_cl table. After that the cycle undergoes the set of all readers and creates triggers in the MySQL standTo add a custom view that will keep tabs on for changes in your Mview index tables you just need to build an mview.xml data file in the module directory.

View more : product design tools

Let's describe one at a time what each discussion is in charge ofFor example, let's take a code sample from the component Catalog-Permission:

This code creates the catalogpermissions_category_cl table which is subscribed for changes in catalog_category_entity and catalog_category_entity_int tables' data. The data from entity_column - entity_id will be transmitted to the *_cl table. This will result in the causes of the next type:

 

For catalog_category_entity:

Re-indexing will be performed by the object of the school field (start to see the $action adjustable in the above code). But you might have pointed out that we haven't used the registration_model field. This attribute is saved in the <table> field and this implies the category which is accountable for creating sets off and their syntax. Certain causes may not be as easy as described above. In such cases one needs to use a custom model that is inherited from the default one. Here's an example of such a model from Magento 2 EE:

 

While you see, the body of the cause differs from the trigger which we created the first time.

From the above example you may observe how simple and chic a incomplete index is. You can redefine existing subscriptions without the problems (there were such circumstances with the EE version when the designers simply forgot about the Staging component) as well as define your own subscriptions to utilize custom indexes.299

Tân Thịnh, Thái Nguyên
  • Share this ad: pictute pictute pictute pictute
  • Print: pictute
  • Add to favorites: pictute
  • Report: pictute