Пример #1
0
 /**
  * @return mixed
  */
 public function getAfterElementHtml()
 {
     $html = parent::getAfterElementHtml();
     /**
      * getEntityAttribute - use __call
      */
     $addJsObserver = false;
     if ($attribute = $this->getEntityAttribute()) {
         if (!($storeId = $attribute->getStoreId())) {
             $storeId = $this->getForm()->getDataObject()->getStoreId();
         }
         $store = $this->_storeManager->getStore($storeId);
         $html .= '<strong>' . $this->_localeCurrency->getCurrency($store->getBaseCurrencyCode())->getSymbol() . '</strong>';
         if ($this->_taxData->priceIncludesTax($store)) {
             if ($attribute->getAttributeCode() !== 'cost') {
                 $addJsObserver = true;
                 $html .= ' <strong>[' . __('Inc. Tax') . '<span id="dynamic-tax-' . $attribute->getAttributeCode() . '"></span>]</strong>';
             }
         }
     }
     if ($addJsObserver) {
         $html .= $this->_getTaxObservingCode($attribute);
     }
     return $html;
 }
Пример #2
0
 /**
  * @param \Magento\Framework\Locale\FormatInterface $localeFormat
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency
  * @param string $code
  * @param int $rate
  */
 public function __construct(\Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, $code, $rate = 1)
 {
     $this->_localeFormat = $localeFormat;
     $this->_storeManager = $storeManager;
     $this->_currency = $localeCurrency->getCurrency($code);
     $this->_rate = $rate;
 }
Пример #3
0
 public function testRenderPrice()
 {
     $this->_appConfig->expects($this->once())->method('getValue')->will($this->returnValue('USD'));
     $currency = $this->getMock('Zend_Currency', array(), array(), '', false);
     $currency->expects($this->once())->method('toCurrency')->with('100.0000')->will($this->returnValue('$100.00'));
     $this->_locale->expects($this->once())->method('getCurrency')->with('USD')->will($this->returnValue($currency));
     $this->assertEquals('$100.00', $this->_block->renderPrice(100));
 }
Пример #4
0
 /**
  * @dataProvider getOutputFormatDataProvider
  * @param $withCurrency
  * @param $noCurrency
  * @param $expected
  */
 public function testGetOutputFormat($withCurrency, $noCurrency, $expected)
 {
     $currencyMock = $this->getMockBuilder('\\Magento\\Framework\\Currency')->disableOriginalConstructor()->getMock();
     $currencyMock->expects($this->at(0))->method('toCurrency')->willReturn($withCurrency);
     $currencyMock->expects($this->at(1))->method('toCurrency')->willReturn($noCurrency);
     $this->localeCurrencyMock->expects($this->atLeastOnce())->method('getCurrency')->with($this->currencyCode)->willReturn($currencyMock);
     $this->assertEquals($expected, $this->currency->getOutputFormat());
 }
Пример #5
0
 public function testGetCurrencySymbol()
 {
     $currencySymbol = '$';
     $currencyMock = $this->getMockBuilder('\\Magento\\Framework\\Currency')->disableOriginalConstructor()->getMock();
     $currencyMock->expects($this->once())->method('getSymbol')->willReturn($currencySymbol);
     $this->localeCurrencyMock->expects($this->once())->method('getCurrency')->with($this->currencyCode)->willReturn($currencyMock);
     $this->assertEquals($currencySymbol, $this->currency->getCurrencySymbol());
 }
Пример #6
0
 /**
  * @return \Magento\Framework\Phrase|mixed
  * @throws \Zend_Currency_Exception
  */
 public function getMessage()
 {
     $message = $this->scopeConfig->getValue('sales/minimum_order/description', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if (!$message) {
         $currencyCode = $this->storeManager->getStore()->getCurrentCurrencyCode();
         $minimumAmount = $this->currency->getCurrency($currencyCode)->toCurrency($this->scopeConfig->getValue('sales/minimum_order/amount', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
         $message = __('Minimum order amount is %1', $minimumAmount);
     }
     return $message;
 }
Пример #7
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     if ($data = (string) $this->_getValue($row)) {
         $currency_code = $this->_getCurrencyCode($row);
         $data = floatval($data) * $this->_getRate($row);
         $sign = (bool) (int) $this->getColumn()->getShowNumberSign() && $data > 0 ? '+' : '';
         $data = sprintf("%f", $data);
         $data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data);
         return $sign . $data;
     }
     return $this->getColumn()->getDefault();
 }
 /**
  * Validate minimum amount and display notice in error
  *
  * @return void
  */
 protected function validateMinimumAmount()
 {
     if (!$this->cartHelper->getQuote()->validateMinimumAmount()) {
         $warning = $this->_scopeConfig->getValue('sales/minimum_order/description', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         if (!$warning) {
             $currencyCode = $this->_storeManager->getStore()->getCurrentCurrencyCode();
             $minimumAmount = $this->currency->getCurrency($currencyCode)->toCurrency($this->_scopeConfig->getValue('sales/minimum_order/amount', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
             $warning = __('Minimum order amount is %1', $minimumAmount);
         }
         $this->messageManager->addNotice($warning);
     }
 }
Пример #9
0
 /**
  * Prepare Data Source
  *
  * @param array $dataSource
  * @return array
  */
 public function prepareDataSource(array $dataSource)
 {
     if (isset($dataSource['data']['items'])) {
         $store = $this->storeManager->getStore($this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID));
         $currency = $this->localeCurrency->getCurrency($store->getBaseCurrencyCode());
         $fieldName = $this->getData('name');
         foreach ($dataSource['data']['items'] as &$item) {
             if (isset($item[$fieldName])) {
                 $item[$fieldName] = $currency->toCurrency(sprintf("%f", $item[$fieldName]));
             }
         }
     }
     return $dataSource;
 }
Пример #10
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     if ($data = $this->_getValue($row)) {
         $currencyCode = $this->_getCurrencyCode($row);
         if (!$currencyCode) {
             return $data;
         }
         $data = floatval($data) * $this->_getRate($row);
         $data = sprintf("%f", $data);
         $data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data);
         return $data;
     }
     return $this->getColumn()->getDefault();
 }
 /**
  * {@inheritdoc}
  */
 public function getConfig()
 {
     $quoteId = $this->checkoutSession->getQuote()->getId();
     $output['formKey'] = $this->formKey->getFormKey();
     $output['customerData'] = $this->getCustomerData();
     $output['quoteData'] = $this->getQuoteData();
     $output['quoteItemData'] = $this->getQuoteItemData();
     $output['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
     $output['selectedShippingMethod'] = $this->getSelectedShippingMethod();
     $output['storeCode'] = $this->getStoreCode();
     $output['isGuestCheckoutAllowed'] = $this->isGuestCheckoutAllowed();
     $output['isCustomerLoginRequired'] = $this->isCustomerLoginRequired();
     $output['registerUrl'] = $this->getRegisterUrl();
     $output['checkoutUrl'] = $this->getCheckoutUrl();
     $output['pageNotFoundUrl'] = $this->pageNotFoundUrl();
     $output['forgotPasswordUrl'] = $this->getForgotPasswordUrl();
     $output['staticBaseUrl'] = $this->getStaticBaseUrl();
     $output['priceFormat'] = $this->localeFormat->getPriceFormat(null, $this->checkoutSession->getQuote()->getQuoteCurrencyCode());
     $output['basePriceFormat'] = $this->localeFormat->getPriceFormat(null, $this->currencyManager->getDefaultCurrency());
     $output['postCodes'] = $this->postCodesConfig->getPostCodes();
     $output['imageData'] = $this->imageProvider->getImages($quoteId);
     $output['defaultCountryId'] = $this->directoryHelper->getDefaultCountry();
     $output['totalsData'] = $this->getTotalsData();
     $output['shippingPolicy'] = ['isEnabled' => $this->scopeConfig->isSetFlag('shipping/shipping_policy/enable_shipping_policy', ScopeInterface::SCOPE_STORE), 'shippingPolicyContent' => nl2br($this->scopeConfig->getValue('shipping/shipping_policy/shipping_policy_content', ScopeInterface::SCOPE_STORE))];
     $output['activeCarriers'] = $this->getActiveCarriers();
     $output['originCountryCode'] = $this->getOriginCountryCode();
     $output['paymentMethods'] = $this->getPaymentMethods();
     $output['autocomplete'] = $this->isAutocompleteEnabled();
     return $output;
 }
Пример #12
0
 /**
  * Check is isset default display currency in allowed currencies
  * Check allowed currencies is available in installed currencies
  *
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 public function afterSave()
 {
     $exceptions = [];
     foreach ($this->_getAllowedCurrencies() as $currencyCode) {
         if (!in_array($currencyCode, $this->_getInstalledCurrencies())) {
             $exceptions[] = __('Selected allowed currency "%1" is not available in installed currencies.', $this->_localeCurrency->getCurrency($currencyCode)->getName());
         }
     }
     if (!in_array($this->_getCurrencyDefault(), $this->_getAllowedCurrencies())) {
         $exceptions[] = __('Default display currency "%1" is not available in allowed currencies.', $this->_localeCurrency->getCurrency($this->_getCurrencyDefault())->getName());
     }
     if ($exceptions) {
         throw new \Magento\Framework\Model\Exception(join("\n", $exceptions));
     }
     return $this;
 }
Пример #13
0
 /**
  * Prepare read-only data and group it by fieldsets
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     /* @var $model \Magento\Paypal\Model\Report\Settlement\Row */
     $model = $this->_coreRegistry->registry('current_transaction');
     $fieldsets = ['reference_fieldset' => ['fields' => ['transaction_id' => ['label' => $this->_settlement->getFieldLabel('transaction_id')], 'invoice_id' => ['label' => $this->_settlement->getFieldLabel('invoice_id')], 'paypal_reference_id' => ['label' => $this->_settlement->getFieldLabel('paypal_reference_id')], 'paypal_reference_id_type' => ['label' => $this->_settlement->getFieldLabel('paypal_reference_id_type'), 'value' => $model->getReferenceType($model->getData('paypal_reference_id_type'))], 'custom_field' => ['label' => $this->_settlement->getFieldLabel('custom_field')]], 'legend' => __('Reference Information')], 'transaction_fieldset' => ['fields' => ['transaction_event_code' => ['label' => $this->_settlement->getFieldLabel('transaction_event_code'), 'value' => sprintf('%s (%s)', $model->getData('transaction_event_code'), $model->getTransactionEvent($model->getData('transaction_event_code')))], 'transaction_initiation_date' => ['label' => $this->_settlement->getFieldLabel('transaction_initiation_date'), 'value' => $this->formatDate($model->getData('transaction_initiation_date'), \IntlDateFormatter::MEDIUM, true)], 'transaction_completion_date' => ['label' => $this->_settlement->getFieldLabel('transaction_completion_date'), 'value' => $this->formatDate($model->getData('transaction_completion_date'), \IntlDateFormatter::MEDIUM, true)], 'transaction_debit_or_credit' => ['label' => $this->_settlement->getFieldLabel('transaction_debit_or_credit'), 'value' => $model->getDebitCreditText($model->getData('transaction_debit_or_credit'))], 'gross_transaction_amount' => ['label' => $this->_settlement->getFieldLabel('gross_transaction_amount'), 'value' => $this->_localeCurrency->getCurrency($model->getData('gross_transaction_currency'))->toCurrency($model->getData('gross_transaction_amount'))]], 'legend' => __('Transaction Information')], 'fee_fieldset' => ['fields' => ['fee_debit_or_credit' => ['label' => $this->_settlement->getFieldLabel('fee_debit_or_credit'), 'value' => $model->getDebitCreditText($model->getCastedAmount('fee_debit_or_credit'))], 'fee_amount' => ['label' => $this->_settlement->getFieldLabel('fee_amount'), 'value' => $this->_localeCurrency->getCurrency($model->getData('fee_currency'))->toCurrency($model->getCastedAmount('fee_amount'))]], 'legend' => __('PayPal Fee Information')]];
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     foreach ($fieldsets as $key => $data) {
         $fieldset = $form->addFieldset($key, ['legend' => $data['legend']]);
         foreach ($data['fields'] as $id => $info) {
             $fieldset->addField($id, 'label', ['name' => $id, 'label' => $info['label'], 'title' => $info['label'], 'value' => isset($info['value']) ? $info['value'] : $model->getData($id)]);
         }
     }
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #14
0
 public function testPrepareDataSource()
 {
     $fieldName = 'special_field';
     $baseCurrencyCode = 'USD';
     $currencySymbol = '$';
     $dataSource = ['data' => ['items' => [['id' => '1', $fieldName => 3], ['id' => '2'], ['id' => '3', $fieldName => 4.55]]]];
     $result = ['data' => ['items' => [['id' => '1', $fieldName => '3.00$', 'price_number' => '3.00', 'price_currency' => $currencySymbol], ['id' => '2'], ['id' => '3', $fieldName => '4.55$', 'price_number' => '4.55', 'price_currency' => $currencySymbol]]]];
     $this->contextMock->expects($this->any())->method('getFilterParam')->with('store_id', Store::DEFAULT_STORE_ID)->willReturn(Store::DEFAULT_STORE_ID);
     $this->storeManagerMock->expects($this->any())->method('getStore')->with(Store::DEFAULT_STORE_ID)->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getBaseCurrencyCode')->willReturn($baseCurrencyCode);
     $this->localeCurrencyMock->expects($this->any())->method('getCurrency')->with($baseCurrencyCode)->willReturn($this->currencyMock);
     $this->currencyMock->expects($this->any())->method('toCurrency')->willReturnMap([['3.000000', ['display' => false], '3.00'], ['4.550000', ['display' => false], '4.55'], ['3.000000', [], '3.00$'], ['4.550000', [], '4.55$']]);
     $this->storeMock->expects($this->any())->method('getBaseCurrency')->willReturn($this->currencyModelMock);
     $this->currencyModelMock->expects($this->any())->method('getCurrencySymbol')->willReturn($currencySymbol);
     $this->priceColumn->setData('name', $fieldName);
     $this->assertSame($result, $this->priceColumn->prepareDataSource($dataSource));
 }
Пример #15
0
 /**
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function afterSave()
 {
     /** @var $collection \Magento\Config\Model\ResourceModel\Config\Data\Collection */
     $collection = $this->_configsFactory->create();
     $collection->addPathFilter('currency/options');
     $values = explode(',', $this->getValue());
     $exceptions = [];
     foreach ($collection as $data) {
         $match = false;
         $scopeName = __('Default scope');
         if (preg_match('/(base|default)$/', $data->getPath(), $match)) {
             if (!in_array($data->getValue(), $values)) {
                 $currencyName = $this->_localeCurrency->getCurrency($data->getValue())->getName();
                 if ($match[1] == 'base') {
                     $fieldName = __('Base currency');
                 } else {
                     $fieldName = __('Display default currency');
                 }
                 switch ($data->getScope()) {
                     case ScopeConfigInterface::SCOPE_TYPE_DEFAULT:
                         $scopeName = __('Default scope');
                         break;
                     case \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE:
                         /** @var $website \Magento\Store\Model\Website */
                         $website = $this->_websiteFactory->create();
                         $websiteName = $website->load($data->getScopeId())->getName();
                         $scopeName = __('website(%1) scope', $websiteName);
                         break;
                     case \Magento\Store\Model\ScopeInterface::SCOPE_STORE:
                         /** @var $store \Magento\Store\Model\Store */
                         $store = $this->_storeFactory->create();
                         $storeName = $store->load($data->getScopeId())->getName();
                         $scopeName = __('store(%1) scope', $storeName);
                         break;
                 }
                 $exceptions[] = __('Currency "%1" is used as %2 in %3.', $currencyName, $fieldName, $scopeName);
             }
         }
     }
     if ($exceptions) {
         throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions)));
     }
     return parent::afterSave();
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 protected function createModel()
 {
     $this->currencyMock = $this->getMockBuilder(CurrencyInterface::class)->setMethods(['getCurrency', 'toCurrency'])->getMockForAbstractClass();
     $this->currencyMock->expects($this->any())->method('getCurrency')->willReturn($this->currencyMock);
     $this->imageHelperMock = $this->getMockBuilder(ImageHelper::class)->setMethods(['init', 'getUrl'])->disableOriginalConstructor()->getMock();
     $this->imageHelperMock->expects($this->any())->method('init')->willReturn($this->imageHelperMock);
     $this->attributeSetRepositoryMock = $this->getMockBuilder(AttributeSetRepositoryInterface::class)->setMethods(['get'])->getMockForAbstractClass();
     $attributeSetMock = $this->getMockBuilder(AttributeSetInterface::class)->setMethods(['getAttributeSetName'])->getMockForAbstractClass();
     $this->attributeSetRepositoryMock->expects($this->any())->method('get')->willReturn($attributeSetMock);
     return $this->objectManager->getObject(Grouped::class, ['locator' => $this->locatorMock, 'productLinkRepository' => $this->linkRepositoryMock, 'productRepository' => $this->productRepositoryMock, 'localeCurrency' => $this->currencyMock, 'imageHelper' => $this->imageHelperMock, 'attributeSetRepository' => $this->attributeSetRepositoryMock]);
 }
Пример #17
0
 /**
  * @param null|int|string $index
  * @return null|string
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getEscapedValue($index = null)
 {
     $values = $this->getValue();
     if (!is_array($values)) {
         return null;
     }
     foreach ($values as $key => $value) {
         $price = array_key_exists('price', $value) ? $value['price'] : $value['value'];
         try {
             if ($attribute = $this->getEntityAttribute()) {
                 $store = $this->getStore($attribute);
                 $currency = $this->localeCurrency->getCurrency($store->getBaseCurrencyCode());
                 $values[$key]['value'] = $currency->toCurrency($price, ['display' => Currency::NO_SYMBOL]);
             } else {
                 // default format:  1234.56
                 $values[$key]['value'] = number_format($price, 2, null, '');
             }
         } catch (\Exception $e) {
             $values[$key]['value'] = $price;
         }
     }
     return $values;
 }
Пример #18
0
 /**
  * @param float $price
  * @param array $options
  * @return string
  */
 public function formatTxt($price, $options = array())
 {
     if (!is_numeric($price)) {
         $price = $this->_localeFormat->getNumber($price);
     }
     /**
      * Fix problem with 12 000 000, 1 200 000
      *
      * %f - the argument is treated as a float, and presented as a floating-point number (locale aware).
      * %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
      */
     $price = sprintf("%F", $price);
     return $this->_localeCurrency->getCurrency($this->getCode())->toCurrency($price, $options);
 }
Пример #19
0
 /**
  * Prepare group price values
  *
  * @return array
  */
 public function getValues()
 {
     $values = [];
     $data = $this->getElement()->getValue();
     if (is_array($data)) {
         $values = $this->_sortValues($data);
     }
     $currency = $this->_localeCurrency->getCurrency($this->_directoryHelper->getBaseCurrencyCode());
     foreach ($values as &$value) {
         $value['readonly'] = $value['website_id'] == 0 && $this->isShowWebsiteColumn() && !$this->isAllowChangeWebsite();
         $value['price'] = $currency->toCurrency($value['price'], ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
     }
     return $values;
 }
Пример #20
0
 /**
  * @param null|int|string $index
  * @return null|string
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getEscapedValue($index = null)
 {
     $value = $this->getValue();
     if (!is_numeric($value)) {
         return null;
     }
     if ($attribute = $this->getEntityAttribute()) {
         // honor the currency format of the store
         $store = $this->getStore($attribute);
         $currency = $this->_localeCurrency->getCurrency($store->getBaseCurrencyCode());
         $value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
     } else {
         // default format:  1234.56
         $value = number_format($value, 2, null, '');
     }
     return $value;
 }
Пример #21
0
 /**
  * Prepare variations
  *
  * @return void
  * @throws \Zend_Currency_Exception
  */
 protected function prepareVariations()
 {
     $variations = $this->getVariations();
     $productMatrix = [];
     $attributes = [];
     $productIds = [];
     if ($variations) {
         $usedProductAttributes = $this->getUsedAttributes();
         $productByUsedAttributes = $this->getAssociatedProducts();
         $currency = $this->localeCurrency->getCurrency($this->locator->getBaseCurrencyCode());
         $configurableAttributes = $this->getAttributes();
         foreach ($variations as $variation) {
             $attributeValues = [];
             foreach ($usedProductAttributes as $attribute) {
                 $attributeValues[$attribute->getAttributeCode()] = $variation[$attribute->getId()]['value'];
             }
             $key = implode('-', $attributeValues);
             if (isset($productByUsedAttributes[$key])) {
                 $product = $productByUsedAttributes[$key];
                 $price = $product->getPrice();
                 $variationOptions = [];
                 foreach ($usedProductAttributes as $attribute) {
                     if (!isset($attributes[$attribute->getAttributeId()])) {
                         $attributes[$attribute->getAttributeId()] = ['code' => $attribute->getAttributeCode(), 'label' => $attribute->getStoreLabel(), 'id' => $attribute->getAttributeId(), 'position' => $configurableAttributes[$attribute->getAttributeId()]['position'], 'chosen' => []];
                         foreach ($attribute->getOptions() as $option) {
                             if (!empty($option->getValue())) {
                                 $attributes[$attribute->getAttributeId()]['options'][$option->getValue()] = ['attribute_code' => $attribute->getAttributeCode(), 'attribute_label' => $attribute->getStoreLabel(0), 'id' => $option->getValue(), 'label' => $option->getLabel(), 'value' => $option->getValue()];
                             }
                         }
                     }
                     $optionId = $variation[$attribute->getId()]['value'];
                     $variationOption = ['attribute_code' => $attribute->getAttributeCode(), 'attribute_label' => $attribute->getStoreLabel(0), 'id' => $optionId, 'label' => $variation[$attribute->getId()]['label'], 'value' => $optionId];
                     $variationOptions[] = $variationOption;
                     $attributes[$attribute->getAttributeId()]['chosen'][$optionId] = $variationOption;
                 }
                 $productMatrix[] = ['id' => $product->getId(), 'product_link' => '<a href="' . $this->urlBuilder->getUrl('catalog/product/edit', ['id' => $product->getId()]) . '" target="_blank">' . $product->getName() . '</a>', 'sku' => $product->getSku(), 'name' => $product->getName(), 'qty' => $this->getProductStockQty($product), 'price' => $currency->toCurrency(sprintf("%f", $price), ['display' => false]), 'price_string' => $currency->toCurrency(sprintf("%f", $price)), 'price_currency' => $this->locator->getStore()->getBaseCurrency()->getCurrencySymbol(), 'configurable_attribute' => $this->getJsonConfigurableAttributes($variationOptions), 'weight' => $product->getWeight(), 'status' => $product->getStatus(), 'variationKey' => $this->getVariationKey($variationOptions), 'canEdit' => 0, 'newProduct' => 0, 'attributes' => $this->getTextAttributes($variationOptions), 'thumbnail_image' => $this->imageHelper->init($product, 'product_thumbnail_image')->getUrl()];
                 $productIds[] = $product->getId();
             }
         }
     }
     $this->productMatrix = $productMatrix;
     $this->productIds = $productIds;
     $this->productAttributes = array_values($attributes);
 }
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->locator->getProduct();
     $modelId = $product->getId();
     if ($modelId) {
         $storeId = $this->locator->getStore()->getId();
         /** @var \Magento\Framework\Currency $currency */
         $currency = $this->localeCurrency->getCurrency($this->locator->getBaseCurrencyCode());
         $data[$product->getId()]['links'][self::LINK_TYPE] = [];
         foreach ($this->productLinkRepository->getList($product) as $linkItem) {
             if ($linkItem->getLinkType() !== self::LINK_TYPE) {
                 continue;
             }
             /** @var \Magento\Catalog\Api\Data\ProductInterface $linkedProduct */
             $linkedProduct = $this->productRepository->get($linkItem->getLinkedProductSku(), false, $storeId);
             $data[$modelId]['links'][self::LINK_TYPE][] = ['id' => $linkedProduct->getId(), 'name' => $linkedProduct->getName(), 'sku' => $linkItem->getLinkedProductSku(), 'price' => $currency->toCurrency(sprintf("%f", $linkedProduct->getPrice())), 'qty' => $linkItem->getExtensionAttributes()->getQty(), 'position' => $linkItem->getPosition(), 'thumbnail' => $this->imageHelper->init($linkedProduct, 'product_listing_thumbnail')->getUrl(), 'type_id' => $linkedProduct->getTypeId(), 'status' => $this->status->getOptionText($linkedProduct->getStatus()), 'attribute_set' => $this->attributeSetRepository->get($linkedProduct->getAttributeSetId())->getAttributeSetName()];
         }
         $data[$modelId][self::DATA_SOURCE_DEFAULT]['current_store_id'] = $storeId;
     }
     return $data;
 }
Пример #23
0
 /**
  * Get order data jason
  *
  * @return string
  */
 public function getOrderDataJson()
 {
     $data = array();
     if ($this->getCustomerId()) {
         $data['customer_id'] = $this->getCustomerId();
         $data['addresses'] = array();
         $addresses = $this->_addressService->getAddresses($this->getCustomerId());
         foreach ($addresses as $addressData) {
             $addressForm = $this->_customerFormFactory->create('customer_address', 'adminhtml_customer_address', AddressConverter::toFlatArray($addressData));
             $data['addresses'][$addressData->getId()] = $addressForm->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON);
         }
     }
     if (!is_null($this->getStoreId())) {
         $data['store_id'] = $this->getStoreId();
         $currency = $this->_localeCurrency->getCurrency($this->getStore()->getCurrentCurrencyCode());
         $symbol = $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName();
         $data['currency_symbol'] = $symbol;
         $data['shipping_method_reseted'] = !(bool) $this->getQuote()->getShippingAddress()->getShippingMethod();
         $data['payment_method'] = $this->getQuote()->getPayment()->getMethod();
     }
     return $this->_jsonEncoder->encode($data);
 }
Пример #24
0
 /**
  * Return currency symbol for current locale and currency code
  *
  * @return string
  */
 public function getCurrencySymbol()
 {
     return $this->_localeCurrency->getCurrency($this->getCode())->getSymbol();
 }
Пример #25
0
 /**
  * {@inheritdoc}
  */
 public function getConfig()
 {
     return ['formKey' => $this->formKey->getFormKey(), 'customerData' => $this->getCustomerData(), 'quoteData' => $this->getQuoteData(), 'quoteItemData' => $this->getQuoteItemData(), 'isCustomerLoggedIn' => $this->isCustomerLoggedIn(), 'selectedShippingMethod' => $this->getSelectedShippingMethod(), 'storeCode' => $this->getStoreCode(), 'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed(), 'isCustomerLoginRequired' => $this->isCustomerLoginRequired(), 'registerUrl' => $this->getRegisterUrl(), 'customerAddressCount' => $this->getCustomerAddressCount(), 'forgotPasswordUrl' => $this->getForgotPasswordUrl(), 'staticBaseUrl' => $this->getStaticBaseUrl(), 'priceFormat' => $this->localeFormat->getPriceFormat(null, $this->checkoutSession->getQuote()->getQuoteCurrencyCode()), 'basePriceFormat' => $this->localeFormat->getPriceFormat(null, $this->currencyManager->getDefaultCurrency())];
 }
Пример #26
0
 /**
  * Retrieve price rendered according to current locale and currency settings
  *
  * @param int|float $price
  * @return string
  */
 public function renderPrice($price)
 {
     return $this->_localeCurrency->getCurrency($this->_scopeConfig->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default'))->toCurrency(sprintf('%f', $price));
 }
Пример #27
0
 /**
  * Get base application currency
  *
  * @return \Zend_Currency
  */
 public function getBaseCurrency()
 {
     return $this->_localeCurrency->getCurrency($this->_scopeConfig->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default'));
 }
Пример #28
0
 /**
  * Retrieve curency name by code
  *
  * @param string $code
  * @return string
  */
 public function getCurrencySymbol($code)
 {
     $currency = $this->_localeCurrency->getCurrency($code);
     return $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName();
 }
Пример #29
0
 /**
  * Fill data column
  *
  * @param ProductInterface $linkedProduct
  * @param ProductLinkInterface $linkItem
  * @return array
  */
 protected function fillData(ProductInterface $linkedProduct, ProductLinkInterface $linkItem)
 {
     /** @var \Magento\Framework\Currency $currency */
     $currency = $this->localeCurrency->getCurrency($this->locator->getBaseCurrencyCode());
     return ['id' => $linkedProduct->getId(), 'name' => $linkedProduct->getName(), 'sku' => $linkItem->getLinkedProductSku(), 'price' => $currency->toCurrency(sprintf("%f", $linkedProduct->getPrice())), 'qty' => $linkItem->getExtensionAttributes()->getQty(), 'position' => $linkItem->getPosition(), 'thumbnail' => $this->imageHelper->init($linkedProduct, 'product_listing_thumbnail')->getUrl(), 'type_id' => $linkedProduct->getTypeId(), 'status' => $this->status->getOptionText($linkedProduct->getStatus()), 'attribute_set' => $this->attributeSetRepository->get($linkedProduct->getAttributeSetId())->getAttributeSetName()];
 }
 /**
  * @return string
  */
 public function getCurrencySymbol()
 {
     return $this->localeCurrency->getCurrency($this->_storeManager->getStore()->getBaseCurrencyCode())->getSymbol();
 }