Maintenance Module

This custom functionality was introduced to serve the need of running certain repetitive tasks, tracking their progress and sending feedback to assigned individuals. Such tasks include for example: calculate product popularity, check if misconfigured or broken configurable products are present in DB, remove outdated special prices on products. This article describes reasons for creating this module in the first place, how to control it and how to add new jobs.

Even though running tasks based on schedule using Cron is also initially possible in Magento, it requires more work to setup and does not have centralized tools like logging, sending reports to assigned staff and switching certain jobs on/off where necessary. “Maintenance Module” was designed to offer a centralized mechanism for creating and managing all automations and periodic processes either included with itself or introduced by additional modules. Module contains mechanics that run declared jobs, configuration, logging mechanism to track execution of declared jobs and also base classes that all Jobs need to extend to become a valid Maintenance Job.

Classes containing Job logic can live inside a custom module that they do the job for and can be declared for execution by Maintenance Module using XML configuration. This makes it very easy to create and declare periodic processes and also to be notified any time they are run, this is what needs to be done to get new Maintenance Job up and running:

  • in your module created a new Model class extending “Magforge_Maintenance_Model_Job”. See “Magforge_Tableten_Model_MaintenanceJobs_CalculateProductPopularity” class for example.
  • inside of that class implement function _run() and within that function describe your Job logic. In your code use $this->addOutput(‘string to log’) to register readable output to be emailed when job finishes execution.
  • in your module config declare job using <maintenance></maintenance> tags, so it can be found by Maintenance Module and added to the list of scheduled jobs. See app/code/local/Magforge/Tableten/etc/config.xml for example.
  • configure your new Job in “ikff_magf_maintenance_task” table. There is no GUI for job management and configuration at the moment.

Currently existing Maintenance Jobs

Calculate Product Popularity

Calculates number of times every product was viewed during last 60 days and saves those values to product attribute “popularity”.

Job class: “Magforge_Tableten_Model_MaintenanceJobs_CalculateProductPopularity”.

Check Configurable Products

Checks if there are any broken configurable products in catalog: configurable products without variations or configurable products that were not configured correctly – this can happen due to errors during import.

Job class: “Magforge_Tableten_Model_MaintenanceJobs_CheckConfigurableProducts”.

Translate Attribute Options

Automatically updates attribute option values for .FR shop substituting known simple terms like “red, yellow, rubber, shoes” with their translations in French. This allows to minimize untranslated options visible as configurable product variations on front-end.

Job class: “Magforge_Tableten_Model_MaintenanceJobs_TranslateAttributeOptions”.

Remove Outdated Special Prices

Looks for products that have outdated “special price” or “special price validity dates” or “Promotion Type” and resets them automatically.

Job class: “Magforge_Tableten_Model_MaintenanceJobs_RemoveOutdatedSpecialPrices”.

Remove Attribute Inheritance

Looks for products that have fields that inherit values on .FR shop from .COM shop, like “price”, “status”, “promotion_type” and other (full list in job class) and removes inheritance. Inheriting product field values is a default behavior for Magento and in most cases it is very useful. However, since we have custom logic when it comes to product creation and management, we also need to make sure that certain fields are controlled independently for .COM and .FR websites. This job does exactly that.

Job class: “Magforge_Tableten_Model_MaintenanceJobs_RemoveAttributeInheritance”.

Process Product Statuses

Looks for products that are under Clearance promotion, have Special Price assigned to them and have reached zero stock and changes their status to “Discontinued”.

Looks for products that have “Discontinued” status but have positive stock. This happens when a “discontinued” product was ordered again for some reason and should become available for sale. This check does not change product status automatically to “Enabled” and just sends notification that such products were found.

Job class: “Magforge_Tableten_Model_MaintenanceJobs_ProcessProductStatuses”.

Check Erply Product Codes

Compares product SKUswith Product Erply ID for every product and if they do not match, updates them. This is needed because new products are created in Erply and it assigns generic SKUs to new products. Our policy is however that every product should have a unique number-only SKU, so this job takes care of that.

Job class: “Magforge_Erply_Model_Maintenance_CheckErplyProductCodes”.

Leave a Reply 0

Your email address will not be published. Required fields are marked *