From 7f6c52da8dc1c64e31f4ffb6af2e3ab0542bedc5 Mon Sep 17 00:00:00 2001 From: Ruslan Mavlyanov Date: Wed, 22 Nov 2017 14:19:05 +0300 Subject: [PATCH] [MYGMOD-68] Revert method getAttributeValueByParam() back to Base helper. (#6) --- Helper/Data.php | 17 +++++++++++++++++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 028f271..6feb0ac 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -195,6 +195,23 @@ public function getCode() return $this->_code; } + /** + * Fetch attribute code from $pathToParam and then get it from product + * @param $pathToParam config path like module/general/param + * @param $productId + * + * @return mixed attribute value + */ + public function getAttrValueByParam($pathToParam, $productId) + { + $attributeCode = $this->getConfig($pathToParam); + if (!$attributeCode || '0' == $attributeCode || 0 === $attributeCode) { + return $this->getConfig($pathToParam . '_default'); + } + + return $this->getAttributeValue($attributeCode, $productId); + } + public function getAttributeValue($attributeCode, $productId) { $product = $this->getProduct($productId); diff --git a/composer.json b/composer.json index 8e1e4bb..2620d61 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mygento/base", "type": "magento2-module", - "version": "2.2.4", + "version": "2.2.5", "license": "OSL-3.0", "homepage": "https://github.com/mygento/base", "description": "Mygento Base", diff --git a/etc/module.xml b/etc/module.xml index 0a9b0cc..bd6f5cd 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -7,5 +7,5 @@ */ --> - +