Magento get file paths and URLs
Get URL paths of your magento folder structure – Absolute URL Path
Mage::getBaseUrl() => Gets base url path e.g. http://my.website.com/
Mage::getBaseUrl(‘media’) => Gets MEDIA folder path e.g. http://my.website.com/media/
Mage::getBaseUrl(‘js’) => Gets JS folder path e.g. http://my.website.com/js/
Mage::getBaseUrl(‘skin’) => Gets SKIN folder path e.g. http://my.website.com/skin/
Get DIRECTORY paths (physical location of your folders on the server) – Relative URL Path
Mage::getBaseDir() => Gives you your Magento installation folder / root folder e.g. /home/kalpesh/workspace/magento
Mage::getBaseDir(‘app’) => Gives you your Magento’s APP directory file location e.g. /home/kalpesh/workspace/magento/app
Mage::getBaseDir(‘design’) => Gives you your Magento’s DESIGN directory file location e.g. /home/kalpesh/workspace/magento/design
Mage::getBaseDir(‘media’) => Gives MEDIA directory file path
Mage::getBaseDir(‘code’) => Gives CODE directory file path
Mage::getBaseDir(‘lib’) => Gives LIB directory file path
Get Current URL – whole URL path
Mage::helper(‘core/url’)->getCurrentUrl()
10 Comments
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)
Hi man! I really like what you’re providing here. Keep working that way.
Also check it many more
base Mage::getBaseDir()
Mage::getBaseDir(‘base’) /var/www/magento/
app Mage::getBaseDir(‘app’) /var/www/magento/app/
code Mage::getBaseDir(‘code’) /var/www/magento/app/code
design Mage::getBaseDir(‘design’) /var/www/magento/app/design/
etc Mage::getBaseDir(‘etc’) /var/www/magento/app/etc
lib Mage::getBaseDir(‘lib’) /var/www/magento/lib
locale Mage::getBaseDir(‘locale’) /var/www/magento/app/locale
media Mage::getBaseDir(‘media’) /var/www/magento/media/
skin Mage::getBaseDir(‘skin’) /var/www/magento/skin/
var Mage::getBaseDir(‘var’) /var/www/magento/var/
tmp Mage::getBaseDir(‘tmp’) /var/www/magento/var/tmp
cache Mage::getBaseDir(‘cache’) /var/www/magento/var/cache
log Mage::getBaseDir(‘log’) /var/www/magento/var/log
session Mage::getBaseDir(‘session’) /var/www/magento/var/session
upload Mage::getBaseDir(‘upload’) /var/www/magento/media/upload
export Mage::getBaseDir(‘export’) /var/www/magento/var/export
Awesome work man, great information about magento.
Awesome post.
Very informative for me and so much thanks to you.
Hi Kalpesh,
thank you for your post. I’m a bit of a newbie and this may sound silly, but I have the following issue:
– I can connect via SSH, using Mac Terminal, to the server where my Magento is installed;
– to find out what the root directory is, shall I just type one of the commands above in the Terminal while the SSH connection is open? If not, where shall I type the commands?
Thank you very much!
Hi giulia, the code in this blog post is used to call from Magento files. like phtml, php files in Magento. Root directory should be something like /var/www/magento or public_html/magento, which you can confirm from terminal while SSH is open for your server.
Thanks for your help Kalpesh. The issue is I haven’t installed the magento site I need to work on, and the root folder seems not to be in any of the standard ones (e.g. /var/www). Is there a fast way I can find the root folder of Magento from SSH or do I need to go folder by folder, maybe with a program like Filezilla, and try to locate the files? Thank you very much!
Ok. You need to first ensure whether apache, mysql and php are installed or not. You can check it by executing below commands
If all those required things are installed, you can come to know what is your apache directory root at /etc/apache2/sites-available/default OR /etc/httpd/sites-available/default
If apache is not installed, you will need to install it. You can get that help online how to install apache, mysql and php in linux.
Hello
I was trying to take media backup of my magento website from the server and deploying on my local host but in the catalogue page product image is not showing the path for media is taking from the below url
http://127.0.0.1/Storemediaall/media/C:/wamp64/www/Storemediaall/media/product/aab/advantagec05.jpg
how to fix this media url