Skip to content

Instantly share code, notes, and snippets.

@coderbyheart
Last active December 15, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderbyheart/5300260 to your computer and use it in GitHub Desktop.
Save coderbyheart/5300260 to your computer and use it in GitHub Desktop.
Payone 3.1.2 Patch for Payone_Core_Model_Payment_Method_Abstract::getTitle()

Patch for Payone_Core_Model_Payment_Method_Abstract

Payone version: 3.1.2

This patch updates Payone_Core_Model_Payment_Method_Abstract to use the payment method configuration for the title.

Currently the configured strings from Payone/Core/etc/sytem.xml are used (e.g. payone_creditcard).

This patch enables the use of the value configured in the admin section.

Pull-Request

I've created a PR for this: https://github.com/PAYONE/magento/pull/5

diff --git a/app/code/community/Payone/Core/Model/Payment/Method/Abstract.php b/app/code/community/Payone/Core/Model/Payment/Method/Abstract.php
index e8d3e1b..d898e6c 100644
--- a/app/code/community/Payone/Core/Model/Payment/Method/Abstract.php
+++ b/app/code/community/Payone/Core/Model/Payment/Method/Abstract.php
@@ -429,4 +429,34 @@ abstract class Payone_Core_Model_Payment_Method_Abstract
return $this->methodType;
}
+ /**
+ * Retrieve payment method title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ $config = $this->getPaymentMethodConfig();
+ return $config === null ? parent::getTitle() : $config->getName();
+ }
+
+ /**
+ * Retrieve information from payment method configuration
+ *
+ * @author Markus Tacker <m@coderbyheart.de>
+ * @param int|null $storeId
+ * @return Payone_Core_Model_Config_Payment_Method_Interface
+ */
+ public function getPaymentMethodConfig($storeId = null)
+ {
+ if ($storeId === null) {
+ $store = $this->getData('store');
+ $storeId = ($store instanceof Mage_Core_Model_Store) ? $store->getId() : $store;
+ }
+ /** @var $config Payone_Core_Helper_Config */
+ $config = Mage::helper('payone_core/config');
+ $methods = $config->getConfigPayment($storeId)->getMethodsByType(preg_replace('/^payone_/', '', $this->getCode()));
+ return count($methods) == 1 ? array_shift($methods) : null;
+ }
+
}
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment