From d544c4b58bfba2a289c29512f5c4b47e64572262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6rmann?= Date: Thu, 27 May 2021 16:06:50 +0200 Subject: [PATCH 1/5] Added option to define custom CSS classes for shoppingworld elements. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Hörmann --- MNAddEmotionAttributes.php | 21 +++++++++++++++++++ .../views/frontend/_includes/emotion.tpl | 19 +++++++++++++++++ plugin.xml | 6 +++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Resources/views/frontend/_includes/emotion.tpl diff --git a/MNAddEmotionAttributes.php b/MNAddEmotionAttributes.php index cff3dfe..31dd234 100644 --- a/MNAddEmotionAttributes.php +++ b/MNAddEmotionAttributes.php @@ -22,6 +22,7 @@ public static function getSubscribedEvents() { return [ 'Enlight_Controller_Action_PostDispatchSecure_Frontend_Listing' => 'onFrontendListing', + 'Enlight_Controller_Action_PostDispatchSecure_Frontend_Index' => 'onFrontendListing', 'Enlight_Controller_Action_PostDispatchSecure_Frontend' => 'onFrontend' ]; } @@ -41,6 +42,25 @@ public function install(InstallContext $context) ['key' => '2', 'value' => 'Nach Listing'] ], ]); + + $service->update('s_emotion_attributes', 'mncssclasses', 'string', [ + 'label' => 'Eigene CSS Klassen', + 'supportText' => 'Mehrere CSS Klassen mit Leerzeichen trennen', + 'displayInBackend' => true, + 'arrayStore' => [ + ['key' => '1', 'value' => 'Vor Listing'], + ['key' => '2', 'value' => 'Nach Listing'] + ], + ]); + } + + /** + * @param InstallContext $context + * @throws \Exception + */ + public function update(InstallContext $context) + { + return $this->install($context); } /** @@ -51,6 +71,7 @@ public function uninstall(UninstallContext $context) { $service = $this->container->get('shopware_attribute.crud_service'); $service->delete('s_emotion_attributes', 'mnposition'); + $service->delete('s_emotion_attributes', 'mncssclasses'); } diff --git a/Resources/views/frontend/_includes/emotion.tpl b/Resources/views/frontend/_includes/emotion.tpl new file mode 100644 index 0000000..0360777 --- /dev/null +++ b/Resources/views/frontend/_includes/emotion.tpl @@ -0,0 +1,19 @@ +{block name="frontend_includes_emotion"} + +{/block} diff --git a/plugin.xml b/plugin.xml index 04e5c59..420ab23 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ - 1.0.0 + 1.0.1 https://github.com/mnaczenski/ Moritz Naczenski @@ -12,4 +12,8 @@ Veröffentlichung Release + + Option hinzugefügt der Einkaufswelt zusätzliche CSS Klassen zu geben. + Added option to define custom CSS classes for shoppingworld elements. + From 15a5f869a2dc9450c34ef7de2e6f2d6e9f136708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6rmann?= Date: Fri, 4 Jun 2021 11:01:27 +0200 Subject: [PATCH 2/5] Array of $emotions can have missing indexes. This causes a fatal error in the assignment with $i. I suppose when shopping worlds get removed from $emotions the array is not re-indexed. Maybe this happens when shopping worlds get deactivated. I did not investigate this more deeply, just fixed the code. --- MNAddEmotionAttributes.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MNAddEmotionAttributes.php b/MNAddEmotionAttributes.php index cff3dfe..2c45d0c 100644 --- a/MNAddEmotionAttributes.php +++ b/MNAddEmotionAttributes.php @@ -1,5 +1,6 @@ container->get('shopware_attribute.data_loader'); - $i = 0; - foreach ($emotions as $emotion) + foreach ($emotions as $key => $emotion) { $attributes['attributes'] = $service->load('s_emotion_attributes', $emotion['id']); - $emotions[$i] = $emotions[$i] + $attributes; - $i++; + $emotions[$key] = array_merge($emotion, $attributes); } $view->assign('emotions', $emotions); From e657c22530f800069a271769202417e79e3f624d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6rmann?= Date: Wed, 18 Aug 2021 17:39:17 +0200 Subject: [PATCH 3/5] Custom CSS classes do not work on landing-pages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Hörmann --- MNAddEmotionAttributes.php | 40 +++++++++++++++++++++++++++++++------- plugin.xml | 6 +++++- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/MNAddEmotionAttributes.php b/MNAddEmotionAttributes.php index bb23995..d7fd63d 100644 --- a/MNAddEmotionAttributes.php +++ b/MNAddEmotionAttributes.php @@ -24,6 +24,7 @@ public static function getSubscribedEvents() return [ 'Enlight_Controller_Action_PostDispatchSecure_Frontend_Listing' => 'onFrontendListing', 'Enlight_Controller_Action_PostDispatchSecure_Frontend_Index' => 'onFrontendListing', + 'Enlight_Controller_Action_PostDispatchSecure_Frontend_Campaign' => 'onFrontendCampaign', 'Enlight_Controller_Action_PostDispatchSecure_Frontend' => 'onFrontend' ]; } @@ -70,6 +71,10 @@ public function update(InstallContext $context) */ public function uninstall(UninstallContext $context) { + if ($context->keepUserData()) { + return; + } + $service = $this->container->get('shopware_attribute.crud_service'); $service->delete('s_emotion_attributes', 'mnposition'); $service->delete('s_emotion_attributes', 'mncssclasses'); @@ -89,16 +94,27 @@ public function onFrontendListing(\Enlight_Event_EventArgs $args) $emotions = $view->getAssign('emotions'); + $this->updateEmotions($emotions); - $service = $this->container->get('shopware_attribute.data_loader'); + $view->assign('emotions', $emotions); + } - foreach ($emotions as $key => $emotion) - { - $attributes['attributes'] = $service->load('s_emotion_attributes', $emotion['id']); - $emotions[$key] = array_merge($emotion, $attributes); - } + /** + * @param \Enlight_Event_EventArgs $args + * @throws \Exception + */ - $view->assign('emotions', $emotions); + public function onFrontendCampaign(\Enlight_Event_EventArgs $args) + { + /** @var \Enlight_Controller_Action $controller */ + $controller = $args->get('subject'); + $view = $controller->View(); + + $landingPage = $view->getAssign('landingPage'); + + $this->updateEmotions($landingPage['emotions']); + + $view->assign('landingPage', $landingPage); } public function onFrontend(\Enlight_Event_EventArgs $args) @@ -113,4 +129,14 @@ public function onFrontend(\Enlight_Event_EventArgs $args) ); } } + + private function updateEmotions(&$emotions) { + $service = $this->container->get('shopware_attribute.data_loader'); + + foreach ($emotions as $key => $emotion) + { + $attributes['attributes'] = $service->load('s_emotion_attributes', $emotion['id']); + $emotions[$key] = array_merge($emotion, $attributes); + } + } } diff --git a/plugin.xml b/plugin.xml index 420ab23..c91a60f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ - 1.0.1 + 1.0.2 https://github.com/mnaczenski/ Moritz Naczenski @@ -16,4 +16,8 @@ Option hinzugefügt der Einkaufswelt zusätzliche CSS Klassen zu geben. Added option to define custom CSS classes for shoppingworld elements. + + Zusätzliche CSS Klassen werden auf Landingseiten nicht ausgegeben. + Additional CSS Classes not shown in landing pages. + From 75b8bda776270ab2b4a1c0c0bf72c6969ad9de79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6rmann?= Date: Wed, 18 Aug 2021 18:05:41 +0200 Subject: [PATCH 4/5] Remove class import that was added by PHPstorm. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Hörmann --- MNAddEmotionAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MNAddEmotionAttributes.php b/MNAddEmotionAttributes.php index d7fd63d..ea21082 100644 --- a/MNAddEmotionAttributes.php +++ b/MNAddEmotionAttributes.php @@ -1,6 +1,6 @@ Date: Wed, 18 Aug 2021 18:14:36 +0200 Subject: [PATCH 5/5] Clean up Copy&Paste trash. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Hörmann --- MNAddEmotionAttributes.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/MNAddEmotionAttributes.php b/MNAddEmotionAttributes.php index ea21082..4091f0c 100644 --- a/MNAddEmotionAttributes.php +++ b/MNAddEmotionAttributes.php @@ -1,6 +1,5 @@ 'Eigene CSS Klassen', 'supportText' => 'Mehrere CSS Klassen mit Leerzeichen trennen', 'displayInBackend' => true, - 'arrayStore' => [ - ['key' => '1', 'value' => 'Vor Listing'], - ['key' => '2', 'value' => 'Nach Listing'] - ], ]); } @@ -74,7 +69,7 @@ public function uninstall(UninstallContext $context) if ($context->keepUserData()) { return; } - + $service = $this->container->get('shopware_attribute.crud_service'); $service->delete('s_emotion_attributes', 'mnposition'); $service->delete('s_emotion_attributes', 'mncssclasses');