1. roderic
  2. RO CSVI
  3. Friday, 29 March 2024
  4.  Subscribe via email
Good morning,

For a new website I need to export (Advanced) Orders in single files. Manually this is possible, however, with a cronjob it will combine them into one file. Unless I'm overseeing an option to separate them? If it is not possible in any way, consider this as a feature request.

Cheers!
Accepted Answer Pending Moderation
Hello Roderic,

You can specify the order ID on the command line with the cronjob, that way only that order will be exported. You can find more details in the Setting up a cron job document. On a Joomla 4 site you would add --form_fields=orderlist=2 to export order ID 2.

Is that what you are looking for?
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Hello Roland,

No, I have an automatic order export, that exports the last orders since last run. It works well if there was only one order since last run. But if there were more than one in those 5 minutes in-between, it will export all of them in one file. The program that imports those files, only accepts one order per file.
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Hello Roderic,

What do you mean then with this comment:
Manually this is possible
How do you do it manually?
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
Hoi Roland,

Setting the order ID and then hitting "Run template". Then setting the next ID and running the template again. Every time an order comes in.

order-export-id.png

But in an ideal world, I would leave this field empty and there would be an option like "Export every order as single file". This way I can run an automated cronjob.

Cheers
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
Hello Roderic,

Ok, but that also "works" via cron of course, there you can also specify the order ID. Too bad you are running VirtueMart because for HikaShop we have a plugin that is triggered by HikaShop when an order is created and this calls RO CSVI to export the order that has just been created. That would also be a solution.

I just checked the VirtueMart code but do not see any triggers in the order creation process. The only other thing would be a custom script that keeps track of the order IDs but that is some work as well.

Not sure how busy the site is but you could run a cron job every minute to trigger the export. There can still be a race condition that multiple orders are placed within the same minute, otherwise you should more or less have 1 order per file.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 5
Accepted Answer Pending Moderation
Hi Roland,

I just checked the VirtueMart code but do not see any triggers in the order creation process. The only other thing would be a custom script that keeps track of the order IDs but that is some work as well.


I asked a Virtuemart expert yesterday about this, waiting for his reply. Exporting based on a trigger on creation process would be (almost) perfect, this would be the quickest way of getting the orders exported.

But there is another problem. Sometimes the import system doesn't accept a file and for those cases I would like to create another Order export template that runs every, let's say 2 hours, and exports all orders that are still on status "Confirmed by shopper" instead of "Confirmed" (Meaning it's in the bookkeeping system). So let's say there is more than 1 order that needs to be exporting by this fallback template, it would definitely need an option to export one order per file.


Not sure how busy the site is but you could run a cron job every minute to trigger the export. There can still be a race condition that multiple orders are placed within the same minute, otherwise you should more or less have 1 order per file.


I have already set it like this as a temporary solution. But today more orders are coming in and it just happened, that 2 people ordered in the same minute. And a downside of having the cron running every minute, that the CSVI log viewer is almost of no use anymore as it pushes other cronjobs away in the list quickly.


Cheers
  1. more than a month ago
  2. RO CSVI
  3. # 6
Accepted Answer Pending Moderation
Unfortunately, it happened two more times today that users ordered in the same minute. Meaning, one user also gets the order items from the other user. So I have now disabled cron and have to manually export every order until there is a solution.
  1. more than a month ago
  2. RO CSVI
  3. # 7
Accepted Answer Pending Moderation
Hey Roderic,

Meaning, one user also gets the order items from the other user.
How would that work though? Order items are linked to the order ID not based on time.

So let's say there is more than 1 order that needs to be exporting by this fallback template, it would definitely need an option to export one order per file.
That will not be developed anytime soon.

The only thing sort of automated I see at the moment is a bash script that reads a file with one order ID per line and calls the RO CSVI cron with the order ID as argument.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 8
Accepted Answer Pending Moderation
Hello Roderic,

Ok, but that also "works" via cron of course, there you can also specify the order ID. Too bad you are running VirtueMart because for HikaShop we have a plugin that is triggered by HikaShop when an order is created and this calls RO CSVI to export the order that has just been created. That would also be a solution.

I just checked the VirtueMart code but do not see any triggers in the order creation process. The only other thing would be a custom script that keeps track of the order IDs but that is some work as well.

Not sure how busy the site is but you could run a cron job every minute to trigger the export. There can still be a race condition that multiple orders are placed within the same minute, otherwise you should more or less have 1 order per file.


Hello Roland,

Coming back to this post, you said, you didn't see any triggers, but there is this trigger in cart.php on line 1936:


$returnValues = vDispatcher::trigger('plgVmConfirmedOrder', array(&$this, $orderDetails));


plgVmConfirmedOrder is then also used in shipment and payment plug-ins.


How would that work though? Order items are linked to the order ID not based on time.


That's just how the import works unfortunately, it just adds all the order_item_sku's to one order, to that of the first customer in the file.


The only thing sort of automated I see at the moment is a bash script that reads a file with one order ID per line and calls the RO CSVI cron with the order ID as argument.


I guess the trigger/plug-in would be possible after all, and the best way of getting there? Just like in Hikashop.



As a temporary work-around, a collegeau made some changes to the advancedorder.php and I am using that now as a Override. These changes limit the export to one order per file (It will only export one order per run). This file is attached. Changes made:
image.png

Cheers
Attachments (2)
  1. more than a month ago
  2. RO CSVI
  3. # 9
Accepted Answer Pending Moderation
Hello Roderic,

you said, you didn't see any triggers, but there is this trigger in cart.php on line 1936:
Correct, I was looking for a trigger after the order has been paid. This trigger is called just when a customer confirms the order regardless of payment.

That's just how the import works unfortunately, it just adds all the order_item_sku's to one order, to that of the first customer in the file.
I see you mean in the target system, not in the export file itself. I thought you meant that RO CSVI exported it all as a single order.

plgVmConfirmedOrder is then also used in shipment and payment plug-ins.
Correct, they use it to see if something need to be shipped or a payment must be performed. You could clone one these plugins and just act on that trigger. You can check the HikaShop export plugin for the code to trigger RO CSVI. That way you would have a working solution as well.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 10
Accepted Answer Pending Moderation
Hoi Roland,

I haven't had time to look at the plug-in yet. As I'm working on other issues, the override does it work. However, I only found out on Monday, that the override isn't being taken into account when running the template in a cronjob. Only when running the template manually through the admin. Is there a way to force the cronjob to use the override? Currently I made the override changes to the original file, which of course will be overwritten on next update.

Cheers
  1. more than a month ago
  2. RO CSVI
  3. # 11
Accepted Answer Pending Moderation
Hello Roderic,

That is a bit odd because all imports run through the same import routine. I will check if I can find out why the override is not used but most likely because it cannot find the override.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 12
Accepted Answer Pending Moderation
Hello Roderic,

So I did some testing on the override and I see my override used in both browser, CLI on J3 and CLI on J4/5. Which Joomla version are you running? Does you classname match the name of the file? If your file is located in templates/atum/html/com_csvi/com_virtuemart/model/export/roderic.php, the classname should be roderic as well.

In case you want to peek into the code, you can find the override loading in the file administrator/components/com_csvi/rantai/import/model.php from line 562 onwards.

Let me know what you find.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 13
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!