/** * Handle the mapping of the fields from the product template to the product */ protected function mapFieldsFromProductTemplate() { if (!empty($this->product_template_id) && $this->fetched_row['product_template_id'] != $this->product_template_id) { /* @var $pt ProductTemplate */ $pt = BeanFactory::getBean('ProductTemplates', $this->product_template_id); $this->category_id = $pt->category_id; $this->mft_part_num = $pt->mft_part_num; $this->list_price = SugarCurrency::convertAmount($pt->list_price, $pt->currency_id, $this->currency_id); $this->cost_price = SugarCurrency::convertAmount($pt->cost_price, $pt->currency_id, $this->currency_id); $this->discount_price = SugarCurrency::convertAmount($pt->discount_price, $pt->currency_id, $this->currency_id); // discount_price = unit price on the front end... $this->list_usdollar = $pt->list_usdollar; $this->cost_usdollar = $pt->cost_usdollar; $this->discount_usdollar = $pt->discount_usdollar; $this->tax_class = $pt->tax_class; $this->weight = $pt->weight; } }
public function displayListPlain($layout_def) { $value = parent::displayListPlain($layout_def); $row_currency = $this->getCurrency($layout_def); $format_id = $row_currency['currency_id']; global $current_user; // when the group by function is empty, and we should show the user prefered currency, it should convert it if (empty($layout_def['group_function']) && $current_user->getPreference('currency_show_preferred')) { $user_currency = SugarCurrency::getUserLocaleCurrency(); if ($user_currency->id != $row_currency['currency_id']) { $value = SugarCurrency::convertAmount($value, $row_currency['currency_id'], $user_currency->id); $format_id = $user_currency->id; } } return SugarCurrency::formatAmountUserLocale($value, $format_id); }