[-] BO : BugFix : #PSCFV-2798 : Multistore : BUG on the "modify products page" with another shop device
This commit is contained in:
@@ -120,7 +120,7 @@ jQuery(document).ready(Customer.init);
|
||||
<label>{l s='Pre-tax wholesale price:'}</label>
|
||||
</td>
|
||||
<td style="padding-bottom:5px;">
|
||||
{$currency->prefix}<input size="11" maxlength="14" name="wholesale_price" id="wholesale_price" type="text" value="{$product->wholesale_price|string_format:'%.2f'}" onchange="this.value = this.value.replace(/,/g, '.');" />{$currency->suffix}
|
||||
{$currency->prefix}<input size="11" maxlength="14" name="wholesale_price" id="wholesale_price" type="text" value="{{toolsConvertPrice price=$product->wholesale_price}|string_format:'%.2f'}" onchange="this.value = this.value.replace(/,/g, '.');" />{$currency->suffix}
|
||||
<p class="preference_description">{l s='The wholesale price at which you bought this product'}</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -131,8 +131,8 @@ jQuery(document).ready(Customer.init);
|
||||
<label>{l s='Pre-tax retail price:'}</label>
|
||||
</td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<input type="hidden" id="priceTEReal" name="price" value="{$product->price}" />
|
||||
{$currency->prefix}<input size="11" maxlength="14" id="priceTE" name="price_displayed" type="text" value="{$product->price|string_format:'%.2f'}" onchange="noComma('priceTE'); $('#priceTEReal').val(this.value);" onkeyup="$('#priceType').val('TE'); $('#priceTEReal').val(this.value.replace(/,/g, '.')); if (isArrowKey(event)) return; calcPriceTI();" />{$currency->suffix}
|
||||
<input type="hidden" id="priceTEReal" name="price" value="{toolsConvertPrice price=$product->price}" />
|
||||
{$currency->prefix}<input size="11" maxlength="14" id="priceTE" name="price_displayed" type="text" value="{{toolsConvertPrice price=$product->price}|string_format:'%.2f'}" onchange="noComma('priceTE'); $('#priceTEReal').val(this.value);" onkeyup="$('#priceType').val('TE'); $('#priceTEReal').val(this.value.replace(/,/g, '.')); if (isArrowKey(event)) return; calcPriceTI();" />{$currency->suffix}
|
||||
<p class="preference_description">{l s='The pre-tax retail price to sell this product'}</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
+11
-2
@@ -414,12 +414,21 @@ class ToolsCore
|
||||
if ((int)$cookie->id_currency)
|
||||
{
|
||||
$currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
|
||||
if (is_object($currency) && (int)$currency->id && (int)$currency->deleted != 1 && $currency->active && $currency->isAssociatedToShop())
|
||||
return $currency;
|
||||
if (is_object($currency) && (int)$currency->id && (int)$currency->deleted != 1 && $currency->active)
|
||||
if ($currency->isAssociatedToShop())
|
||||
return $currency;
|
||||
else
|
||||
{
|
||||
// get currency from context
|
||||
$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
|
||||
$cookie->id_currency = $currency[0]['id_currency'];
|
||||
return Currency::getCurrencyInstance((int)$cookie->id_currency);
|
||||
}
|
||||
}
|
||||
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
if (is_object($currency) && $currency->id)
|
||||
$cookie->id_currency = (int)$currency->id;
|
||||
|
||||
return $currency;
|
||||
}
|
||||
|
||||
|
||||
@@ -312,9 +312,10 @@ class AdminControllerCore extends Controller
|
||||
// Get the name of the folder containing the custom tpl files
|
||||
$this->tpl_folder = Tools::toUnderscoreCase(substr($this->controller_name, 5)).'/';
|
||||
|
||||
$this->context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
|
||||
$this->initShopContext();
|
||||
|
||||
$currency = Shop::getEntityIds('currency', $this->context->shop->id);
|
||||
$this->context->currency = new Currency($currency[0]['id_currency']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -991,4 +991,21 @@ class ShopCore extends ObjectModel
|
||||
Tools::displayAsDeprecated();
|
||||
return Context::getContext()->shop->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $entity
|
||||
* @param int $id_shop
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getEntityIds($entity, $id_shop)
|
||||
{
|
||||
if (!Shop::isTableAssociated($entity))
|
||||
return false;
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT `id_'.pSQL($entity).'`
|
||||
FROM `'._DB_PREFIX_.pSQL($entity).'_shop`
|
||||
WHERE `id_shop` = '.(int)$id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ smartyRegisterFunction($smarty, 'function', 'p', 'smartyShowObject'); // Debug o
|
||||
smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject'); // Debug only
|
||||
smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false);
|
||||
smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook');
|
||||
smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');
|
||||
|
||||
smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
|
||||
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
|
||||
@@ -188,6 +189,11 @@ function smartyHook($params, &$smarty)
|
||||
}
|
||||
}
|
||||
|
||||
function toolsConvertPrice($params, &$smarty)
|
||||
{
|
||||
return Tools::convertPrice($params['price'], Context::getContext()->currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to delay loading of external classes with smarty->register_plugin
|
||||
*/
|
||||
|
||||
@@ -279,7 +279,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
/* update product final price */
|
||||
for ($i = 0; $i < $nb; $i++)
|
||||
{
|
||||
// convert price with the currency from context
|
||||
$this->_list[$i]['price'] = Tools::convertPrice($this->_list[$i]['price'], $this->context->currency, true, $this->context);
|
||||
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 6, null, false, true, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orderByPriceFinal == 'price_final')
|
||||
@@ -2686,6 +2690,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$data->assign('ecotaxTaxRate', Tax::getProductEcotaxRate());
|
||||
$data->assign('tax_exclude_taxe_option', Tax::excludeTaxeOption());
|
||||
$data->assign('ps_use_ecotax', Configuration::get('PS_USE_ECOTAX'));
|
||||
$product_price = Tools::convertPrice($product->price, $this->context->currency, true, $this->context);
|
||||
if ($product->unit_price_ratio != 0)
|
||||
$data->assign('unit_price', Tools::ps_round($product->price / $product->unit_price_ratio, 2));
|
||||
else
|
||||
@@ -3423,7 +3428,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
$combination_images = $product->getCombinationImages($this->context->language->id);
|
||||
foreach ($combinations as $k => $combination)
|
||||
{
|
||||
$price = Tools::displayPrice($combination['price'], $currency);
|
||||
$price_to_convert = Tools::convertPrice($combination['price'], $currency);
|
||||
$price = Tools::displayPrice($price_to_convert, $currency);
|
||||
|
||||
$comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
|
||||
$comb_array[$combination['id_product_attribute']]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']);
|
||||
|
||||
Reference in New Issue
Block a user