From ce4a96c2799c95a0011240545f70b77bfb0c305a Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Fri, 22 Nov 2024 21:34:45 +0100 Subject: [PATCH] [Added] manufacturer to details; Component\ArticleDetails extension method to call the settings on the details page --- IntelliSenseHelper.php | 9 +++++ .../Widgets/ArticleDetailsManufacturer.php | 37 +++++++++++++++++++ .../Model/ManufacturerInfoList.php | 2 +- metadata.php | 3 ++ .../page/details/inc/accordeon.html.twig | 2 +- .../default/page/details/inc/tabs.html.twig | 20 ---------- 6 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 Modules/Application/Component/Widgets/ArticleDetailsManufacturer.php delete mode 100644 views/twig/extensions/themes/default/page/details/inc/tabs.html.twig diff --git a/IntelliSenseHelper.php b/IntelliSenseHelper.php index b247e4d..49fb87d 100644 --- a/IntelliSenseHelper.php +++ b/IntelliSenseHelper.php @@ -26,3 +26,12 @@ namespace D3\ManufacturerInformation\Modules\Application\Model{ { } } + +namespace D3\ManufacturerInformation\Modules\Application\Component\Widgets{ + + use OxidEsales\Eshop\Application\Component\Widget\ArticleDetails; + + class ArticleDetailsManufacturer_parent extends ArticleDetails + { + } +} diff --git a/Modules/Application/Component/Widgets/ArticleDetailsManufacturer.php b/Modules/Application/Component/Widgets/ArticleDetailsManufacturer.php new file mode 100644 index 0000000..e10fa9f --- /dev/null +++ b/Modules/Application/Component/Widgets/ArticleDetailsManufacturer.php @@ -0,0 +1,37 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\ManufacturerInformation\Modules\Application\Component\Widgets; + +use D3\ManufacturerInformation\Application\Component\Widget\ArticleDetailsManufacturer_parent; +use D3\ManufacturerInformation\Application\Model\Constants; +use OxidEsales\EshopCommunity\Core\Di\ContainerFacade; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; + +class ArticleDetailsManufacturer extends ArticleDetailsManufacturer_parent +{ + /** + * @param string $sName + * @return bool + */ + public function d3GetBoolModuleSettingByName(string $sName): bool + { + $moduleSettingService = ContainerFacade::get(ModuleSettingServiceInterface::class); + + return $moduleSettingService->getBoolean(Constants::OXID_MODULE_ID.$sName, Constants::OXID_MODULE_ID); + } +} diff --git a/Modules/Application/Model/ManufacturerInfoList.php b/Modules/Application/Model/ManufacturerInfoList.php index d65f255..f2ad45e 100644 --- a/Modules/Application/Model/ManufacturerInfoList.php +++ b/Modules/Application/Model/ManufacturerInfoList.php @@ -36,7 +36,7 @@ class ManufacturerInfoList extends ManufacturerInfoList_parent if (Registry::getConfig()->getConfigParam('d3manufacturerinformation_showManufacturertextOnManufacturerPage')) { $oManufacturer->oxcategories__oxlongdesc = new Field( html_entity_decode( - $oManufacturer->getFieldData( Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME ) ?? '' + $oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME) ?? '' ), Field::T_RAW ); diff --git a/metadata.php b/metadata.php index 8438069..4396a94 100644 --- a/metadata.php +++ b/metadata.php @@ -17,8 +17,10 @@ declare(strict_types=1); use D3\ManufacturerInformation\Application\Controller\Admin\ManufacturerInfoLongdesc; use D3\ManufacturerInformation\Application\Model\Constants; +use D3\ManufacturerInformation\Modules\Application\Component\Widgets\ArticleDetailsManufacturer; use D3\ManufacturerInformation\Modules\Application\Model\D3ManufacturerLongDesc; use D3\ManufacturerInformation\Modules\Application\Model\ManufacturerInfoList; +use OxidEsales\Eshop\Application\Component\Widget\ArticleDetails as OEArticleDetails; use OxidEsales\Eshop\Application\Model\Manufacturer as OEManufacturer; use OxidEsales\Eshop\Application\Model\ManufacturerList as OEManufacturerList; @@ -48,6 +50,7 @@ $aModule = [ 'extend' => [ OEManufacturer::class => D3ManufacturerLongDesc::class, OEManufacturerList::class => ManufacturerInfoList::class, + OEArticleDetails::class => ArticleDetailsManufacturer::class, ], 'templates' => [ '@' . Constants::OXID_MODULE_ID . '/admin/d3manufacturerlongdesc.tpl' => 'views/smarty/admin/d3manufacturerlongdesc.tpl', diff --git a/views/twig/extensions/themes/default/page/details/inc/accordeon.html.twig b/views/twig/extensions/themes/default/page/details/inc/accordeon.html.twig index 8ae631a..24538b4 100644 --- a/views/twig/extensions/themes/default/page/details/inc/accordeon.html.twig +++ b/views/twig/extensions/themes/default/page/details/inc/accordeon.html.twig @@ -7,7 +7,7 @@ {% set sShopURL = config.getConfigParam('sShopURL') %} {% set description = oManufacturer.d3GetLongdesc() %} - {% if oManufacturer and true and description|striptags|trim %} + {% if oManufacturer and oView.d3GetBoolModuleSettingByName('_showManufacturertextOnDetailsPage') and description|striptags|trim %}