From 8b089dfcfa78412830538aa60eaa6e4453f05caf Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Sun, 13 Jan 2019 00:53:18 +0300 Subject: [PATCH 1/5] downloadable product view layout fix (issue #20187) 1) This fixes only catalog product view layout of of downloadables. The layout now is similar to simple or other types 2) Now the links are shown on frontend only if they sell separately or have samples. (Previously meaningless names of links also appeared) 3) Duplicate links title "Links" was removed as well. The layout on wishlist and maybe somewhere else still pending --- ...catalog_product_view_type_downloadable.xml | 16 +-- .../templates/catalog/product/links.phtml | 111 ++++++++++-------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml b/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml index 45e5f0b8da72d..5942e4a4d480c 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml @@ -7,7 +7,6 @@ --> - @@ -26,21 +25,8 @@ - - - - product.price.render.default - final_price - 1 - item_view - copy- - - - - - - + diff --git a/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml b/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml index 5548279a1118b..9f22eb4c482be 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml @@ -13,52 +13,67 @@ getLinks(); ?> getLinkSelectionRequired(); ?> - escapeHtml($block->getLinksTitle()) ?>
-
- - - - - -
+ getSampleFile() || $_link->getSampleUrl()) { + $samples = true; + break; + } + } + ?> + + escapeHtml($block->getLinksTitle()) ?>
*/ ?> +
+ + + + + +
+ From ec8c973fb1665206eebe603bf64e3f6d13fcdea4 Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Fri, 18 Jan 2019 14:18:42 +0300 Subject: [PATCH 2/5] Shortening the list of currencies This will shorten the list of allowed currencies showing only installed currencies (Replace closed pr#19946) --- .../Model/Config/Source/Locale/Currency.php | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php index b3474674cf76d..5dc08475a7ca8 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php @@ -24,13 +24,28 @@ class Currency implements \Magento\Framework\Option\ArrayInterface * @var \Magento\Framework\Locale\ListsInterface */ protected $_localeLists; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $_config; + + /** + * @var Currency + */ + protected $_installedCurrencies; + /** * @param \Magento\Framework\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Framework\Locale\ListsInterface $localeLists) + public function __construct( + \Magento\Framework\Locale\ListsInterface $localeLists, + \Magento\Framework\App\Config\ScopeConfigInterface $config + ) { $this->_localeLists = $localeLists; + $this->_config = $config; } /** @@ -41,7 +56,36 @@ public function toOptionArray() if (!$this->_options) { $this->_options = $this->_localeLists->getOptionCurrencies(); } - $options = $this->_options; + $options = []; + $selected = $this->_getInstalledCurrencies(); + + foreach ($this->_options as $option) { + if (!in_array($option['value'], $selected)) { + continue; + } + $options[] = $option; + } return $options; } + + /** + * Retrieve Installed Currencies + * + * @return string[] + */ + protected function _getInstalledCurrencies() + { + if (!$this->_installedCurrencies) + { + $this->_installedCurrencies = explode( + ',', + $this->_config->getValue( + 'system/currency/installed', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); + } + return $this->_installedCurrencies; + } + } From 796496239b617654f0475f65436d83526e9028ec Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Mon, 21 Jan 2019 21:37:23 +0300 Subject: [PATCH 3/5] Small optimization --- .../Config/Model/Config/Source/Locale/Currency.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php index 5dc08475a7ca8..e6288169b36d1 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php @@ -56,15 +56,16 @@ public function toOptionArray() if (!$this->_options) { $this->_options = $this->_localeLists->getOptionCurrencies(); } - $options = []; + $selected = $this->_getInstalledCurrencies(); - foreach ($this->_options as $option) { - if (!in_array($option['value'], $selected)) { - continue; + $options = array_filter( + $this->_options, + function ($option) use ($selected) { + return in_array($option['value'], $selected); } - $options[] = $option; - } + ); + return $options; } From 0ce045d0ace8995fce3de133c91ccff947006034 Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Thu, 24 Jan 2019 14:15:06 +0200 Subject: [PATCH 4/5] Fix static tests. --- .../Model/Config/Source/Locale/Currency.php | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php index e6288169b36d1..754ff834805ea 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php @@ -4,12 +4,15 @@ * See COPYING.txt for license details. */ -/** - * Locale currency source - */ namespace Magento\Config\Model\Config\Source\Locale; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Locale\ListsInterface; + /** + * Locale currency source. + * * @api * @since 100.0.2 */ @@ -21,35 +24,34 @@ class Currency implements \Magento\Framework\Option\ArrayInterface protected $_options; /** - * @var \Magento\Framework\Locale\ListsInterface + * @var ListsInterface */ protected $_localeLists; - + /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ - protected $_config; + private $config; /** - * @var Currency + * @var array */ - protected $_installedCurrencies; - + private $installedCurrencies; /** - * @param \Magento\Framework\Locale\ListsInterface $localeLists + * @param ListsInterface $localeLists + * @param ScopeConfigInterface $config */ public function __construct( - \Magento\Framework\Locale\ListsInterface $localeLists, - \Magento\Framework\App\Config\ScopeConfigInterface $config - ) - { + ListsInterface $localeLists, + ScopeConfigInterface $config = null + ) { $this->_localeLists = $localeLists; - $this->_config = $config; + $this->config = $config ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class); } /** - * @return array + * @inheritdoc */ public function toOptionArray() { @@ -57,36 +59,35 @@ public function toOptionArray() $this->_options = $this->_localeLists->getOptionCurrencies(); } - $selected = $this->_getInstalledCurrencies(); - + $selected = $this->getInstalledCurrencies(); + $options = array_filter( $this->_options, function ($option) use ($selected) { return in_array($option['value'], $selected); } ); - + return $options; } - + /** - * Retrieve Installed Currencies + * Retrieve Installed Currencies. * - * @return string[] + * @return array */ - protected function _getInstalledCurrencies() + private function getInstalledCurrencies() { - if (!$this->_installedCurrencies) - { - $this->_installedCurrencies = explode( - ',', - $this->_config->getValue( - 'system/currency/installed', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ); + if (!$this->installedCurrencies) { + $this->installedCurrencies = explode( + ',', + $this->config->getValue( + 'system/currency/installed', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); } - return $this->_installedCurrencies; - } + return $this->installedCurrencies; + } } From ead255737066e236a4b52a15e183d1c074c56cab Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Fri, 5 Apr 2019 22:06:47 +0300 Subject: [PATCH 5/5] Revert "downloadable product view layout fix (issue #20187)" This reverts commit 8b089dfcfa78412830538aa60eaa6e4453f05caf. --- ...catalog_product_view_type_downloadable.xml | 16 ++- .../templates/catalog/product/links.phtml | 111 ++++++++---------- 2 files changed, 63 insertions(+), 64 deletions(-) diff --git a/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml b/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml index 5942e4a4d480c..45e5f0b8da72d 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml @@ -7,6 +7,7 @@ --> + @@ -25,8 +26,21 @@ + + + + product.price.render.default + final_price + 1 + item_view + copy- + + + - + + + diff --git a/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml b/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml index 9f22eb4c482be..5548279a1118b 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml @@ -13,67 +13,52 @@ getLinks(); ?> getLinkSelectionRequired(); ?> - getSampleFile() || $_link->getSampleUrl()) { - $samples = true; - break; - } - } - ?> - - escapeHtml($block->getLinksTitle()) ?>
*/ ?> -
- - - - - -
- + escapeHtml($block->getLinksTitle()) ?>
+
+ + + + + +