1

Magento2 loading products from external source with a cron job

I'm loading catalog products from external source to my Magento website for that i have wrote 2 processes (2 separate cron jobs).

1st Process : Loads all the products(approx 500+) from external source(with soap) into magento custom table.

2nd Process : At a time this will read first 10 products from the custom table and then it will create csv file with this 10 products and then import csv into Magento catalog . if this process completed successfully then it will delete this 10 records from the custom table . And then this should initiate next run as separate thread This process goes on till custom table becomes empty.

Here 2nd process connected with 1st process ,so i need to setup cron job once 1st process(1st cron) completed then it should start initiating 2nd process(could be 2nd cron).

Suggest me how this can be achieved ?

0

You can create temp file when ever the first cron completed. if you got the file then run the second cron otherwise exit there itself. after execution of second one delete the temp file. so that when ever you have file stop the execution of the first cron.

  • 2nd process cron at a time insert 10 records only once this done then it should initiate next run to insert again 10 . – Grandhi Manikanta Dec 28 '16 at 9:56
0

No depends on first cron. Steps should follow:

  1. first cron always read data and stored in db -> your process fine.
  2. Second cron will take 10 records of first inserted (order by id asc).
  3. In second cron take 10 records and success processed id's should be maintain in array and delete records from table based on this array
  4. NOTE: skip loop when reach execution time 60 secs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.