I have a problem by creating an XML Export for product data.
The PrestaShop Version I'm using is 1.7.3.1
our setup:
One Site xyz.com where we have different routes for our countries .com/de and .com/at and .com/it
our need:
We need a XML File which all products and the writh prices with the right tax calcualation (it's different in de/at and it).
As I call the script via the browser and I'm not logged in.
So I have no country id and the geotagging say I'm from Austria and get for ALL products the tax rate from Austria - Unfortunately it's wrong.
what I tried (one of many things I tried)
When I call the script for Italy I set the global context country to IT.
switch ( $shop ) {
case "DE":
/* .... */
break;
case "AT":
/* .... */
break;
case "IT":
$id_shop = 6;
$id_lang = 4;
$replace = '.com/it/';
$country = Country::getCountriesByZoneId(10, 4);
Shop::setContext(Shop::CONTEXT_SHOP, 6);
Context::getContext()->shop->id = 6;
Context::getContext()->country = $country;
break;
}
but the tax calculation is wrong and I get always the same price for each country.
Do you have ideas, how I could achieve the different tax rates?
Thanks!
The solutuion was instead of
$country = Country::getCountriesByZoneId(10, 4);
Shop::setContext(Shop::CONTEXT_SHOP, 6);
Context::getContext()->shop->id = 6;
Context::getContext()->country = $country;
I use this now
Context::getContext()->country = new Country(/*Enter country ID here*/);