diff --git a/MNAddEmotionAttributes.php b/MNAddEmotionAttributes.php index cff3dfe..4091f0c 100644 --- a/MNAddEmotionAttributes.php +++ b/MNAddEmotionAttributes.php @@ -22,6 +22,8 @@ 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' ]; } @@ -41,6 +43,21 @@ 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, + ]); + } + + /** + * @param InstallContext $context + * @throws \Exception + */ + public function update(InstallContext $context) + { + return $this->install($context); } /** @@ -49,8 +66,13 @@ public function install(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'); } @@ -67,18 +89,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); + } - $i = 0; - foreach ($emotions as $emotion) - { - $attributes['attributes'] = $service->load('s_emotion_attributes', $emotion['id']); - $emotions[$i] = $emotions[$i] + $attributes; - $i++; - } + /** + * @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) @@ -93,4 +124,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/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..c91a60f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ - 1.0.0 + 1.0.2 https://github.com/mnaczenski/ Moritz Naczenski @@ -12,4 +12,12 @@ Veröffentlichung Release + + 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. +