Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Data Class Reference
Inheritance diagram for Data:
AbstractHelper

Public Member Functions

 __construct (\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Registry $registry)
 
 isGoogleAdwordsActive ()
 
 getLanguageCodes ()
 
 convertLanguageCodeToLocaleCode ($language)
 
 getConversionJsSrc ()
 
 getConversionImgSrc ()
 
 getConversionId ()
 
 getConversionLanguage ()
 
 getConversionFormat ()
 
 getConversionColor ()
 
 getConversionLabel ()
 
 getConversionValueType ()
 
 isDynamicConversionValue ()
 
 getConversionValueConstant ()
 
 getConversionValue ()
 
 hasSendConversionValueCurrency ()
 
 getConversionValueCurrency ()
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Data Fields

const XML_PATH_LANGUAGES = 'google/adwords/languages'
 
const XML_PATH_LANGUAGE_CONVERT = 'google/adwords/language_convert'
 
const XML_PATH_CONVERSION_JS_SRC = 'google/adwords/conversion_js_src'
 
const XML_PATH_CONVERSION_IMG_SRC = 'google/adwords/conversion_img_src'
 
const CONVERSION_VALUE_REGISTRY_NAME = 'google_adwords_conversion_value'
 
const CONVERSION_VALUE_CURRENCY_REGISTRY_NAME = 'google_adwords_conversion_value_currency'
 
const CONVERSION_VALUE_DEFAULT = 0
 
const XML_PATH_ACTIVE = 'google/adwords/active'
 
const XML_PATH_CONVERSION_ID = 'google/adwords/conversion_id'
 
const XML_PATH_CONVERSION_LANGUAGE = 'google/adwords/conversion_language'
 
const XML_PATH_CONVERSION_FORMAT = 'google/adwords/conversion_format'
 
const XML_PATH_CONVERSION_COLOR = 'google/adwords/conversion_color'
 
const XML_PATH_CONVERSION_LABEL = 'google/adwords/conversion_label'
 
const XML_PATH_CONVERSION_VALUE_TYPE = 'google/adwords/conversion_value_type'
 
const XML_PATH_CONVERSION_VALUE = 'google/adwords/conversion_value'
 
const XML_PATH_SEND_CURRENCY = 'google/adwords/send_currency'
 
const CONVERSION_VALUE_TYPE_DYNAMIC = 1
 
const CONVERSION_VALUE_TYPE_CONSTANT = 0
 

Protected Attributes

 $_registry
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Detailed Description

@api

Since
100.0.2

Definition at line 14 of file Data.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Helper\Context  $context,
\Magento\Framework\Registry  $registry 
)
Parameters
\Magento\Framework\App\Helper\Context$context
\Magento\Framework\Registry$registry

Definition at line 91 of file Data.php.

94  {
95  parent::__construct($context);
96  $this->_registry = $registry;
97  }

Member Function Documentation

◆ convertLanguageCodeToLocaleCode()

convertLanguageCodeToLocaleCode (   $language)

Convert language code in the code of the current locale language

Parameters
string$language
Returns
string

Definition at line 133 of file Data.php.

134  {
135  $convertArray = (array)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGE_CONVERT, 'default');
136  return isset($convertArray[$language]) ? $convertArray[$language] : $language;
137  }

◆ getConversionColor()

getConversionColor ( )

Get Google AdWords conversion color

Returns
string

Definition at line 207 of file Data.php.

208  {
209  return $this->scopeConfig->getValue(
210  self::XML_PATH_CONVERSION_COLOR,
211  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
212  );
213  }

◆ getConversionFormat()

getConversionFormat ( )

Get Google AdWords conversion format

Returns
int

Definition at line 194 of file Data.php.

195  {
196  return $this->scopeConfig->getValue(
197  self::XML_PATH_CONVERSION_FORMAT,
198  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
199  );
200  }

◆ getConversionId()

getConversionId ( )

Get Google AdWords conversion id

Returns
int

Definition at line 168 of file Data.php.

169  {
170  return (int)$this->scopeConfig->getValue(
171  self::XML_PATH_CONVERSION_ID,
172  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
173  );
174  }

◆ getConversionImgSrc()

getConversionImgSrc ( )

Get conversion img src

Returns
string

Definition at line 154 of file Data.php.

155  {
156  return sprintf(
157  $this->scopeConfig->getValue(self::XML_PATH_CONVERSION_IMG_SRC, 'default'),
158  $this->getConversionId(),
159  $this->getConversionLabel()
160  );
161  }

◆ getConversionJsSrc()

getConversionJsSrc ( )

Get conversion path to js src

Returns
string

Definition at line 144 of file Data.php.

145  {
146  return (string)$this->scopeConfig->getValue(self::XML_PATH_CONVERSION_JS_SRC, 'default');
147  }

◆ getConversionLabel()

getConversionLabel ( )

Get Google AdWords conversion label

Returns
string

Definition at line 220 of file Data.php.

221  {
222  return $this->scopeConfig->getValue(
223  self::XML_PATH_CONVERSION_LABEL,
224  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
225  );
226  }

◆ getConversionLanguage()

getConversionLanguage ( )

Get Google AdWords conversion language

Returns
string

Definition at line 181 of file Data.php.

182  {
183  return $this->scopeConfig->getValue(
184  self::XML_PATH_CONVERSION_LANGUAGE,
185  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
186  );
187  }

◆ getConversionValue()

getConversionValue ( )

Get Google AdWords conversion value

Returns
float

Definition at line 269 of file Data.php.

270  {
271  if ($this->isDynamicConversionValue()) {
272  $conversionValue = (double)$this->_registry->registry(self::CONVERSION_VALUE_REGISTRY_NAME);
273  } else {
274  $conversionValue = $this->getConversionValueConstant();
275  }
276  return empty($conversionValue) ? self::CONVERSION_VALUE_DEFAULT : $conversionValue;
277  }

◆ getConversionValueConstant()

getConversionValueConstant ( )

Get Google AdWords conversion value constant

Returns
float

Definition at line 256 of file Data.php.

257  {
258  return (double)$this->scopeConfig->getValue(
259  self::XML_PATH_CONVERSION_VALUE,
260  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
261  );
262  }

◆ getConversionValueCurrency()

getConversionValueCurrency ( )

Get Google AdWords conversion value currency

Returns
string|false

Definition at line 297 of file Data.php.

298  {
299  if ($this->hasSendConversionValueCurrency()) {
300  return (string) $this->_registry->registry(self::CONVERSION_VALUE_CURRENCY_REGISTRY_NAME);
301  }
302  return false;
303  }

◆ getConversionValueType()

getConversionValueType ( )

Get Google AdWords conversion value type

Returns
string

Definition at line 233 of file Data.php.

234  {
235  return $this->scopeConfig->getValue(
236  self::XML_PATH_CONVERSION_VALUE_TYPE,
237  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
238  );
239  }

◆ getLanguageCodes()

getLanguageCodes ( )

Retrieve language codes from config

Returns
string[]

Definition at line 122 of file Data.php.

123  {
124  return (array)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGES, 'default');
125  }

◆ hasSendConversionValueCurrency()

hasSendConversionValueCurrency ( )

Get send order currency to Google Adwords

Returns
boolean

Definition at line 284 of file Data.php.

285  {
286  return $this->scopeConfig->isSetFlag(
287  self::XML_PATH_SEND_CURRENCY,
288  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
289  );
290  }

◆ isDynamicConversionValue()

isDynamicConversionValue ( )

Checks if conversion value is dynamic

Returns
bool

Definition at line 246 of file Data.php.

◆ isGoogleAdwordsActive()

isGoogleAdwordsActive ( )

Is Google AdWords active

Returns
bool

Definition at line 104 of file Data.php.

105  {
106  return $this->scopeConfig->isSetFlag(
107  self::XML_PATH_ACTIVE,
108  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
109  ) &&
110  $this->getConversionId() &&
111  $this->getConversionLanguage() &&
112  $this->getConversionFormat() &&
113  $this->getConversionColor() &&
114  $this->getConversionLabel();
115  }

Field Documentation

◆ $_registry

$_registry
protected

#- #-

Definition at line 85 of file Data.php.

◆ CONVERSION_VALUE_CURRENCY_REGISTRY_NAME

const CONVERSION_VALUE_CURRENCY_REGISTRY_NAME = 'google_adwords_conversion_value_currency'

Google AdWords registry name for conversion value currency

Definition at line 42 of file Data.php.

◆ CONVERSION_VALUE_DEFAULT

const CONVERSION_VALUE_DEFAULT = 0

Default value for conversion value

Definition at line 47 of file Data.php.

◆ CONVERSION_VALUE_REGISTRY_NAME

const CONVERSION_VALUE_REGISTRY_NAME = 'google_adwords_conversion_value'

#- Google AdWords registry name for conversion value

Definition at line 37 of file Data.php.

◆ CONVERSION_VALUE_TYPE_CONSTANT

const CONVERSION_VALUE_TYPE_CONSTANT = 0

Definition at line 80 of file Data.php.

◆ CONVERSION_VALUE_TYPE_DYNAMIC

const CONVERSION_VALUE_TYPE_DYNAMIC = 1

#- #+ Conversion value types

Definition at line 78 of file Data.php.

◆ XML_PATH_ACTIVE

const XML_PATH_ACTIVE = 'google/adwords/active'

#+ Google AdWords config data

Definition at line 52 of file Data.php.

◆ XML_PATH_CONVERSION_COLOR

const XML_PATH_CONVERSION_COLOR = 'google/adwords/conversion_color'

Definition at line 60 of file Data.php.

◆ XML_PATH_CONVERSION_FORMAT

const XML_PATH_CONVERSION_FORMAT = 'google/adwords/conversion_format'

Definition at line 58 of file Data.php.

◆ XML_PATH_CONVERSION_ID

const XML_PATH_CONVERSION_ID = 'google/adwords/conversion_id'

Definition at line 54 of file Data.php.

◆ XML_PATH_CONVERSION_IMG_SRC

const XML_PATH_CONVERSION_IMG_SRC = 'google/adwords/conversion_img_src'

Definition at line 30 of file Data.php.

◆ XML_PATH_CONVERSION_JS_SRC

const XML_PATH_CONVERSION_JS_SRC = 'google/adwords/conversion_js_src'

#- #+ Google AdWords conversion src

Definition at line 28 of file Data.php.

◆ XML_PATH_CONVERSION_LABEL

const XML_PATH_CONVERSION_LABEL = 'google/adwords/conversion_label'

Definition at line 62 of file Data.php.

◆ XML_PATH_CONVERSION_LANGUAGE

const XML_PATH_CONVERSION_LANGUAGE = 'google/adwords/conversion_language'

Definition at line 56 of file Data.php.

◆ XML_PATH_CONVERSION_VALUE

const XML_PATH_CONVERSION_VALUE = 'google/adwords/conversion_value'

Definition at line 66 of file Data.php.

◆ XML_PATH_CONVERSION_VALUE_TYPE

const XML_PATH_CONVERSION_VALUE_TYPE = 'google/adwords/conversion_value_type'

Definition at line 64 of file Data.php.

◆ XML_PATH_LANGUAGE_CONVERT

const XML_PATH_LANGUAGE_CONVERT = 'google/adwords/language_convert'

Definition at line 21 of file Data.php.

◆ XML_PATH_LANGUAGES

const XML_PATH_LANGUAGES = 'google/adwords/languages'

#+ Google AdWords language codes

Definition at line 19 of file Data.php.

◆ XML_PATH_SEND_CURRENCY

const XML_PATH_SEND_CURRENCY = 'google/adwords/send_currency'

Google Adwords send order conversion value currency when using dynamic value

Definition at line 71 of file Data.php.


The documentation for this class was generated from the following file: