0

I want all information about the theme in my module code how can I grab the theme information.The Theme that I have in my Magento like WordPress we can get all the themes information is it possible here.

This example is useful for magento 1.X what about magento 2.

Mage::getSingleton('core/design_package')->getPackageList(); Mage::getSingleton('core/design_package')->getThemeList();

  • this is a bit unclear. What information you want about the theme? Give an example – Marius Jul 21 '16 at 6:16
  • @Marius I want theme name and version and all this and i want this info in my module – Ankush Chauhan Jul 21 '16 at 6:28
  • i want to do same thing in magento 2 – Ankush Chauhan Jul 21 '16 at 10:27
2

I know it's an old question, but since I was looking for the same thing, for future visitors:

use Magento\Framework\View\Design\Theme\ListInterface;

...

public function __construct(
    ListInterface $themeList
) {
    $this->themeList = $themeList;
}

public function getThemes()
{
    foreach ($this->themeList as $theme) {
        /** @var \Magento\Theme\Model\Theme $theme */
        // do things
    }
}
| improve this answer | |
0

If Someone needs to get the theme id from theme Name, use below

 use \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory;
...

 

    private $themeCollection;
    
        /**
         * Theming constructor.
         * @param Context $context
         * @param CollectionFactory $themeCollection
         */
        public function __construct(
            Context $context,
            CollectionFactory $themeCollection
        ) {
            parent::__construct($context);
            $this->themeCollection = $themeCollection;
        }
    
        /**
         * @param $themeName
         * @return int
         */
    
        public function getThemeId($themeName)
        {
            $collection = $this->themeCollection->create();
            $collection->addFieldToFilter('theme_path', $themeName);
            if ($collection->getSize() > 0) {
                return $collection->getFirstItem()->getThemeId();
            } else {
                return null;
            }
        }
| improve this answer | |

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.