示例#1
0
 /**
  * Return option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     $languages = [];
     foreach ($this->_helper->getLanguageCodes() as $languageCode) {
         $localeCode = $this->_helper->convertLanguageCodeToLocaleCode($languageCode);
         $translationForSpecifiedLanguage = \Locale::getDisplayLanguage($localeCode, $localeCode);
         $translationForDefaultLanguage = \Locale::getDisplayLanguage($localeCode);
         $label = sprintf('%s / %s (%s)', $this->_uppercaseFilter->filter($translationForSpecifiedLanguage), $translationForDefaultLanguage, $languageCode);
         $languages[] = ['value' => $languageCode, 'label' => $label];
     }
     return $languages;
 }
示例#2
0
 /**
  * @param string $conversionValueConst
  * @param string $returnValue
  * @dataProvider dataProviderForTestConversionValueConstant
  */
 public function testGetConversionValueConstant($conversionValueConst, $returnValue)
 {
     $this->_scopeConfigMock->expects($this->at(0))->method('getValue')->with(\Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_VALUE_TYPE)->will($this->returnValue(\Magento\GoogleAdwords\Helper\Data::CONVERSION_VALUE_TYPE_CONSTANT));
     $this->_registryMock->expects($this->never())->method('registry');
     $this->_scopeConfigMock->expects($this->at(1))->method('getValue')->with(\Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_VALUE)->will($this->returnValue($conversionValueConst));
     $this->assertEquals($returnValue, $this->_helper->getConversionValue());
 }
 /**
  * Set base grand total of order to registry
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return \Magento\GoogleAdwords\Observer\SetConversionValueObserver
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!($this->_helper->isGoogleAdwordsActive() && $this->_helper->isDynamicConversionValue())) {
         return $this;
     }
     $orderIds = $observer->getEvent()->getOrderIds();
     if (!$orderIds || !is_array($orderIds)) {
         return $this;
     }
     $this->_collection->addFieldToFilter('entity_id', ['in' => $orderIds]);
     $conversionValue = 0;
     /** @var $order \Magento\Sales\Model\Order */
     foreach ($this->_collection as $order) {
         $conversionValue += $order->getBaseGrandTotal();
     }
     $this->_registry->register(\Magento\GoogleAdwords\Helper\Data::CONVERSION_VALUE_REGISTRY_NAME, $conversionValue);
     return $this;
 }
示例#4
0
 /**
  * Render block html if Google AdWords is active
  *
  * @return string
  */
 protected function _toHtml()
 {
     return $this->_googleAdwordsData->isGoogleAdwordsActive() ? parent::_toHtml() : '';
 }