- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SetAreaCode and SetStoreId confusion
Hi Community,
I am getting very confused with these two functions and their meaning when importing products programmatically.
I have only one store and need to import products programmatically.
The code seems to be working well and all products are imported.
Before starting the import I have:
- $state->setAreaCode('adminhtml');
Then during the loop of products I have:
- $product->setData('store_id', 0);
or:
- $product->setStoreId(0);
My problem is that some of the settings don't seem to be shown in front-end.
For example:
- the special price from and to dates
I can see that they have been imported correctly in admin but they are not considered in front-end - the description
I can see the description in admin but I can't see it in frontend
Could someone explain to me if I am making a mistake with either of these two parameters (Area Code and Store Id)?
Thanks so much for any help
Jerome
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: SetAreaCode and SetStoreId confusion
This is what I could find out so far:
This topic is also related to my other question here:
I have the feeling that I need to delete the products that I have imported so far before re-importing them programmatically.
Then, I probably have to set my parameters like so:
- $state->setAreaCode('adminhtml'); // this would be the admin area in which I can still make changes later
- $product->setStoreId(1); // this would be the default store id
But to be honest, I am still not entirely sure.
I have done a test:
- I deleted existing product manually
- I have imported the product (with special price) programmatically with
- area code: "adminhtml"
- store id: 1
- product was set correctly and front-end was showing correct special price
- I have change the special price dates in admin to a past date (so that it should not apply anymore)
- front-end is still showing the product with special price... as if nothing had been changed
I am still confused.
How can I import products programmatically with the correct area code and store id so that I still can make changes manually in the back-end?