I am using very similar code to the example code provided by Rusty above. I am having problems with performance. The back-office is very slow re: products and the following line in my view is taking 3 seconds to return on a product with a total of 140 variants :
If I create the same product non-programmatically in the back-office then the above line returns much, much faster. Therefore I am of the opinion that something else should be done after programmatically creating the product.
Does anyone please have an example of code that adds the product and also deals with the performance issues?
Many thanks for your post. I am running the MerchelloProduct Indexer in the Examine Management section of Umbraco after each import. I am doing it manually at the moment but will need to do that programmatically also.
I have found that if I don't add extended content to each of my variants then the GetPropertyValue runs quicker but the back-office still runs very slowly in the Merchello section.
Another issue I was seeing was that the SetCulture method had no effect on the programmatically added products but worked fine on my manually created ones. This is now resolved when I added the detached content for all the languages but the slow back-office and slow front-end calls remain. So it is fairly evident that my code is not quite correct or incomplete.
Create Product with Options from code
I know from https://our.umbraco.org/base/uForum/TopicUrl/59840.aspx how to create a product via code, but what about variants/options? can I create those likewise?
I'm looking to populate a fresh install with about 40 different products each with 1-3 options.
Something like this?
Hi Rusty,
How do I also change product variant prices,sale prices , barcodes etc. in this case?
Perfect! Thank you :-)
I am using very similar code to the example code provided by Rusty above. I am having problems with performance. The back-office is very slow re: products and the following line in my view is taking 3 seconds to return on a product with a total of 140 variants :
If I create the same product non-programmatically in the back-office then the above line returns much, much faster. Therefore I am of the opinion that something else should be done after programmatically creating the product.
Does anyone please have an example of code that adds the product and also deals with the performance issues?
Many thanks for your help.
Just a thought: did you run the indexer for products? I also had performance issues with a lot of variants, until i ran the indexer.
Not sure if/how you can do that programmatically though
Hi Puck,
Many thanks for your post. I am running the MerchelloProduct Indexer in the Examine Management section of Umbraco after each import. I am doing it manually at the moment but will need to do that programmatically also.
I have found that if I don't add extended content to each of my variants then the GetPropertyValue runs quicker but the back-office still runs very slowly in the Merchello section.
Another issue I was seeing was that the SetCulture method had no effect on the programmatically added products but worked fine on my manually created ones. This is now resolved when I added the detached content for all the languages but the slow back-office and slow front-end calls remain. So it is fairly evident that my code is not quite correct or incomplete.
Best regards,
Steve
is working on a reply...