Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. public static function ThemeDetail(){
  2. $objectManager = MagentoFrameworkAppObjectManager::getInstance()
  3. ->get('MagentoFrameworkAppResourceConnection');
  4. $connection= $objectManager->getConnection();
  5. $theme_table = $objectManager->getTableName('theme');
  6. $theme_data = $connection->fetchAll("SELECT * FROM ".$theme_table);
  7. if(!empty($theme_data)){
  8. foreach($theme_data as $theme_name => $value){
  9. $themeArray[] = array('name'=> $theme_data[$theme_name]['theme_title'], 'version'=>'2.0.5');
  10. }
  11.  
  12. return $themeArray;
  13. } else {
  14. return FALSE;
  15. }
  16.  
  17. }
  18.  
  19. MagentoFrameworkAppConfigScopeConfigInterface
  20. MagentoStoreModelStoreManagerInterface
  21. MagentoFrameworkViewDesignThemeThemeProviderInterface
  22.  
  23. public function getThemeData()
  24. {
  25. $themeId = $this->_scopeConfig->getValue(
  26. MagentoFrameworkViewDesignInterface::XML_PATH_THEME_ID,
  27. MagentoStoreModelScopeInterface::SCOPE_STORE,
  28. $this->_storeManager->getStore()->getId()
  29. );
  30.  
  31. /** @var $theme MagentoFrameworkViewDesignThemeInterface */
  32. $theme = $this->_themeProvider->getThemeById($themeId);
  33.  
  34. return $theme->getData();
  35. }
  36.  
  37. Use directly objectmanager is not right way, use __construct() way to define your class inside block is better way to use coding standard.
  38.  
  39. public static function ThemeDetail(){
  40. $connection = $objectManager = MagentoFrameworkAppObjectManager::getInstance()
  41. ->get('MagentoFrameworkAppResourceConnection')->getConnection('MagentoFrameworkAppResourceConnection::DEFAULT_CONNECTION');
  42.  
  43. $version = $objectManager->get('MagentoFrameworkAppProductMetadataInterface');
  44.  
  45.  
  46. $theme_table = $connection->getTableName('theme');
  47. $theme_data = $connection->fetchAll("SELECT * FROM ".$theme_table);
  48.  
  49. $themeArray = array();
  50. if(!empty($theme_data)){
  51. foreach($theme_data as $value){ echo $value['theme_title'];
  52. $themeArray[] = array('name'=> $value['theme_title'], 'version'=>$version->getVersion());
  53. }
  54. } else {
  55. return FALSE;
  56. }
  57.  
  58. echo "<pre>";print_r($themeArray);exit;
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement