diff --git a/admin-dev/init.php b/admin-dev/init.php index d575ab0a4..e94d227dc 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -95,4 +95,5 @@ else $context->cookie = $cookie; $context->link = $link; $context->language = $language; + $context->country = new Country(Configuration::get('PS_COUNTRY_DEFAULT')); } diff --git a/admin-dev/tabs/AdminProducts.php b/admin-dev/tabs/AdminProducts.php index 4288d3fa0..a591e31ff 100644 --- a/admin-dev/tabs/AdminProducts.php +++ b/admin-dev/tabs/AdminProducts.php @@ -36,7 +36,8 @@ class AdminProducts extends AdminTab public function __construct() { global $currentIndex; - + $context = Context::getContext(); + $this->table = 'product'; $this->className = 'Product'; $this->lang = true; @@ -63,7 +64,7 @@ class AdminProducts extends AdminTab LEFT JOIN '._DB_PREFIX_.'stock stock ON stock.id_product = a.id_product AND stock.id_product_attribute = 0 '.Shop::sqlSharedStock('stock').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)Country::getDefaultCountryId().' AND tr.`id_state` = 0) + LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$context->country->id.' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)'; $this->_filter = 'AND cp.`id_category` = '.(int)($this->_category->id); $this->_select = 'cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final, stock.quantity AS quantity'; @@ -1017,6 +1018,8 @@ class AdminProducts extends AdminTab throw new Exception(Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png')); } + if (!$image->createImgFolder()) + throw new Exception(Tools::displayError('An error occurred during new folder creation')); if (!imageResize($subdir.$file, _PS_PROD_IMG_DIR_.$image->getImgPath().'.jpg')) { $image->delete(); @@ -1662,13 +1665,13 @@ class AdminProducts extends AdminTab protected function _displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups) { global $currentIndex; - + $context = Context::getContext(); if (!($obj = $this->loadObject())) return; $specificPrices = SpecificPrice::getByProductId((int)($obj->id)); $specificPricePriorities = SpecificPrice::getPriority((int)($obj->id)); - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - $taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0); + + $taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, $context->country->id, 0, 0); $tmp = array(); foreach ($shops as $shop) @@ -1699,11 +1702,11 @@ class AdminProducts extends AdminTab
'.$this->l('Add a new specific price').'
@@ -1869,7 +1871,7 @@ class AdminProducts extends AdminTab