lsretailomni / lsmag-two

LS Ecommerce - Magento, an ecommerce interface for integrating Magento with LS Central.
https://www.lsretail.com/
10 stars 16 forks source link

Issues in Discount replication #56

Closed ldrooij closed 7 months ago

ldrooij commented 7 months ago

We are encountering some issues with discount replication. Each night the repl_discount_status_reset cronjob is executed. This job removes all discounts in the database and requires all data to be synced again after this. With many discounts and products this process takes much too long and we have a webshop without many discounts for a long time. We can now manage by limiting the number of discounts, but that is not a long term solution. It seems unnecessary to remove all data. Could you please explain why this choice was made? What would it mean if we disable the reset job? Looking into the differences from version 2.4.0 and the currentmaster branch this doesn't seem to be changed in the last version.

We also see that in the repl_discount_create job when an offer has any changes in the ls_replication_repl_discount table that the catalogrule is remove and re-added only using the records that have been added or updated. I'm not really sure if this is a situation that will ever happen, but the a single record within a offer is updated or added the rule will only apply to the updated/added product.

Preconditions (*)

  1. Magento version: 2.4.3-p3
  2. LS Ecommerce Magento version: 2.4.0
  3. LS Commerce version: 2023.10.0
  4. LS Central version: 23.0.1.1005068 (23.0.16.1005180 [13092])
  5. LS Retail partner: TCOG
  6. About 620,000 records in ls_replication_repl_discount
  7. About 468,023 items in webshop
  8. Batch size for discounts at 10,000

Steps to reproduce (*)

  1. Wait til 0:00 and repl_discount_status_reset job to run

Expected result (*)

  1. Discounts are updated only when needed and will stay applied in catalog after being created

Actual result (*)

  1. Catalogrules (catalog discounts) are remove and i takes a long long time for them to be restored. Part of that is due to Magento taking a very long time building the indexes, but with a batch size of 10,000 it also takes about 4 hours to fill the replication table. We could see haw far we can stretch the batch size, but the Magento process time would still kill the time for the discounts to apply.
SyedWaqasNabi commented 7 months ago

Hi @ldrooij,

We have introduce new replication repl_discount_setup to resolve this problem. You can use the latest commerce service version 2024.4.0 and master branch in order to get the discounts instantly without doing the reset.

ldrooij commented 7 months ago

Thanks @SyedWaqasNabi, we are currently in the process of updating, we will ask our LS Retail partner to update LS commerce version too. I saw that there were changes but couldn't figure out exactly what is was for just looking at the code. I do see that the reset cronjobs are still there. Does this not truncate the tables anymore or can we safely disable the nightly reset cronjobs?

SyedWaqasNabi commented 7 months ago

@ldrooij we have implemented a check so it will not truncate with version 2024.4.0 and onwards.