Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from ivanmiskic/feature/fix-config-fallback
Browse files Browse the repository at this point in the history
Fixing configuration fallback for merchant name to store view level
  • Loading branch information
tiamo authored Jan 11, 2019
2 parents 945ea5d + b58b6e2 commit a8f222a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Gateway/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ class Config extends \Magento\Payment\Gateway\Config\Config
const KEY_DISPLAY_ON_SHOPPING_CART = 'display_on_shopping_cart';
const KEY_MERCHANT_NAME_OVERRIDE = 'merchant_name_override';
const KEY_REQUIRE_BILLING_ADDRESS = 'require_billing_address';
const XML_PATH_STORE_INFO_NAME = \Magento\Store\Model\Information::XML_PATH_STORE_INFO_NAME;

private $scopeConfig;
private $ccConfig;
private $icon = [];

/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;

/**
* @var string $storeCode
*/
protected $storeCode;

/**
* Config constructor.
* @param ScopeConfigInterface $scopeConfig
Expand All @@ -27,13 +38,15 @@ class Config extends \Magento\Payment\Gateway\Config\Config
public function __construct(
ScopeConfigInterface $scopeConfig,
CcConfig $ccConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager,
$methodCode = null,
$pathPattern = self::DEFAULT_PATH_PATTERN
)
{
parent::__construct($scopeConfig, $methodCode, $pathPattern);
$this->scopeConfig = $scopeConfig;
$this->ccConfig = $ccConfig;
$this->storeCode = $storeManager->getStore()->getCode();
}

/**
Expand Down Expand Up @@ -63,7 +76,11 @@ public function getMerchantName()
{
$merchantName = $this->getValue(self::KEY_MERCHANT_NAME_OVERRIDE);
if (empty($this->getValue(self::KEY_MERCHANT_NAME_OVERRIDE))) {
return $this->scopeConfig->getValue(\Magento\Store\Model\Information::XML_PATH_STORE_INFO_NAME);
$merchantName = $this->scopeConfig->getValue(
self::XML_PATH_STORE_INFO_NAME,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$this->storeCode
);
}
return $merchantName;
}
Expand Down

0 comments on commit a8f222a

Please sign in to comment.