Monday 24 October 2016

Magento 2

Magengto 2

While working with Magento 2, i come up with some questions. Basically i tried to compare Magento 1. X with Mgento 2.
I think below question might be helpfull to understand Magento folder structure.

Question : What is Bin Folder?

Answer :

- Consist of  CLI programe file
- Consist .htaccess


Question : Where core files stored in Magento 2?

Ans : Can be find at,

\vendor\magento


Question : Where skin, error, js and media file store in Magento 2?
Ans : In Pub folder.


Question : What is Dev Folder?

Answer :

- It Consist Shell folder.


Question : Which folders removed in Magento 2?


Answer :Below are the folders removed in Magento 2,

- downloader
- includes
- Phpinfo


Question :  Where we can find Database connection settings?

Answer: We can find Database connection settings env.php. Below is the location,
app/etc/env.php


'db' =>
  array (
             'table_prefix' => '',
              'connection' =>
   
       array (
                 'default' =>  
                             array (
                                      'host' => 'localhost',
 
                                     'dbname' => '',
   
                                      'username' => '',
   
                                      'password' => '',
     
                                      'active' => '',
   
                                      ),
 
                   ),

                ),

Thursday 6 October 2016

'Service Temporarily Unavailable' on Magento site.

Magento have build mechanism when installing the module. Well, If at the same time of installation any activity runs it show the 'Service Temporarily Unavailable' message at front.
Basically Magento sets the maintenance.flag . Normally Magento create maintenance.flag at the root of the project folder. This avoid the run time error for users.

To return to normal :

You can simply remove the maintenance. Then your store will back to normal..

How to get base url of for multi-store ( Js, Media, skin, web etc.)


First you need to know your store id. To get the store id you can use,

$storeId = Mage::app()->getStore()->getStoreId();

Then, you can easily get the  store, Js, Media, skin, web etc.  Here is the full list,


Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Getting base url of specific store view in Magento.

If you done with multistore then its some time require to get the store url. So you can simply use below code to achive it.
Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

$installer = $this; in install scripts

Installer script funs with context of setup resource class,

Mage_Core_Model_Resource_Setup

So it menace $this is reference to object instantiated from this class. While its not necessary to have this alias, but its nothing but the convention. It's always better to follow best practices with for convention. 

Why Magento PHP files done have closing PHP tags?

Working with Magento you can oberve that controller, module, installer, helper PHP files don't include PHP ending tags. The reson behind is,

1) PHP interpreter accept the missing closing tag in PHP.
2) It avoid the white space when you try to get response from code.