2

I need to a CSS file based on customer attribute when the user is logged.

How can I do this ?

Readed this : https://mage2.pro/t/topic/140 but it's based on backend config.

1

Solution : If it helps, i've added a event in my event.xml

<event name="controller_action_predispatch">
    <observer name="addCSS" instance="Vendore\Module\Observer\AddCSS" shared="false" />
</event>

the related observer :

public function execute(Observer $observer){
    $om = \Magento\Framework\App\ObjectManager::getInstance();
    $page = $om->get('Magento\Framework\View\Page\Config');

    $condition = $this->getConditionResult();
    if($condition){
        $page->addPageAsset('Magento_Theme::css/otherCSS.css');
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.