Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 50 additions & 9 deletions MNAddEmotionAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
];
}
Expand All @@ -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);
}

/**
Expand All @@ -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');
}


Expand All @@ -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)
Expand All @@ -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);
}
}
}
19 changes: 19 additions & 0 deletions Resources/views/frontend/_includes/emotion.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{block name="frontend_includes_emotion"}
<div class="emotion--wrapper{if $emotion.attributes.mncssclasses} {$emotion.attributes.mncssclasses}{/if}" style="display: none"
data-controllerUrl="{url module=widgets controller=emotion action=index emotionId=$emotion.id secret=$previewSecret controllerName=$Controller}"
data-availableDevices="{$emotion.devices}"
data-ajax="{if $theme.ajaxEmotionLoading}true{else}false{/if}"
{if isset($showListing)} data-showListing="{if $showListing == 1}true{else}false{/if}"{/if}{block name="frontend_emotion_include_attributes"}{/block}>
{block name="frontend_includes_emotion_inner"}
{if !$theme.ajaxEmotionLoading}
{block name="frontend_includes_emotion_template"}
<template style="display: none">
{block name="frontend_includes_emotion_template_inner"}
{action module=widgets controller=emotion action=index emotionId=$emotion.id secret=$previewSecret controllerName=$Controller}
{/block}
</template>
{/block}
{/if}
{/block}
</div>
{/block}
10 changes: 9 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<label lang="de">MNAddEmotionAttributes</label>
<label lang="en">MNAddEmotionAttributes</label>

<version>1.0.0</version>
<version>1.0.2</version>
<link>https://github.com/mnaczenski/</link>
<author>Moritz Naczenski</author>
<compatibility minVersion="5.2.0" />
Expand All @@ -12,4 +12,12 @@
<changes lang="de">Veröffentlichung</changes>
<changes lang="en">Release</changes>
</changelog>
<changelog version="1.0.1">
<changes lang="de">Option hinzugefügt der Einkaufswelt zusätzliche CSS Klassen zu geben.</changes>
<changes lang="en">Added option to define custom CSS classes for shoppingworld elements.</changes>
</changelog>
<changelog version="1.0.2">
<changes lang="de">Zusätzliche CSS Klassen werden auf Landingseiten nicht ausgegeben.</changes>
<changes lang="en">Additional CSS Classes not shown in landing pages.</changes>
</changelog>
</plugin>