We import product data using a feed we get from a wholesaler - one full import a week that merges product data and a daily import that only updates price and stock data. I have created a custom attribute called price_incvat and I want this to be populated with the price plus 20% once the product data is updated by the import.
I tried to do this by creating an observer that would update the attribute on the catalog_product_save_before event (see here) without realising that this event would not be triggered by the import. I have tried to use the same code with various other events as listed here but without success. I feel I have been barking up the wrong tree?
Can anyone suggest a better tree to bark up?
-
are you using magmi or the default magento import?NathanielR– NathanielR2015年06月19日 11:05:02 +00:00Commented Jun 19, 2015 at 11:05
-
I am using a module supplied by Stock in the Channel that imports their own datafeed.Alistair67– Alistair672015年06月19日 11:06:10 +00:00Commented Jun 19, 2015 at 11:06
-
Check for events fired by their module if they fire any and attach your observer there. another possible solution would be to modify their extension to update your attribute after it updates the priceNathanielR– NathanielR2015年06月19日 11:21:58 +00:00Commented Jun 19, 2015 at 11:21
-
Thanks. In their config.xml they attach an observer to sinchimport_model_import_after so I attached mine to that too. Doesn't seem to work. Is there a problem with my observer (see link to previous post above)?Alistair67– Alistair672015年06月19日 12:02:51 +00:00Commented Jun 19, 2015 at 12:02
-
Actually, thinking about it, would that event only happen after the entire import, meaning that my observer would be useless at that point? Is there anywhere other than config.xml I could check for events?Alistair67– Alistair672015年06月19日 12:32:21 +00:00Commented Jun 19, 2015 at 12:32
2 Answers 2
Try with one of these events
catalog_product_attribute_update_before //when attribut is updated
catalog_product_prepare_save //when product is saved
-
Thanks for the suggestion. I've tried them now but no dice.Alistair67– Alistair672015年06月19日 13:05:34 +00:00Commented Jun 19, 2015 at 13:05
-
I doubt these two events would fire as the module is using SQL code to update the DatabaseNathanielR– NathanielR2015年06月21日 07:06:46 +00:00Commented Jun 21, 2015 at 7:06
I think there are two ways to go -
Extend the module from Stock in the Channel to calculate price_incvat and save that value in the SQL call.
Run a script after the import that calculates price_incvat and saves it.
If Stock in the Channel fires an event once at the end of the import, you could use an observer to handle triggering a script that would set price_incvat.
Extending the module and adding price_incvat to the SQL would probably be the least amount of code, and you get the performance benefit of SQL.
-
Ideally the SQL option would be the way to go but I am finding it hard to understand the code in the relevant functions (see comment above posted today)Alistair67– Alistair672015年06月25日 13:21:08 +00:00Commented Jun 25, 2015 at 13:21
-
Pursuing option 2, I found a script elsewhere that I could modify to do the job and it works. I have my observer, now I just need the no doubt simple piece of code that it can use to fire the script. Tried googling it but no joy. Can you help?Alistair67– Alistair672015年06月26日 09:58:54 +00:00Commented Jun 26, 2015 at 9:58
-
Guess what. I just found the extremely simple way of exporting the inc VAT price through Simple Google Shopping that I completely missed in the documentation. I didn't need to do any of this. None of it. Deeply embarrassing. Thanks for all your help though, you and @NathanielR both.Alistair67– Alistair672015年06月26日 12:52:02 +00:00Commented Jun 26, 2015 at 12:52
-
Well, sometimes that happens! We have all been there. If you think the solution can be used by others, put it here as an answer and mark it accepted please.AreDubya– AreDubya2015年06月26日 18:51:44 +00:00Commented Jun 26, 2015 at 18:51
Explore related questions
See similar questions with these tags.