Book Image

Magento 1.8 Development Cookbook

By : Bart Delvaux, Nurul Ferdous
Book Image

Magento 1.8 Development Cookbook

By: Bart Delvaux, Nurul Ferdous

Overview of this book

<p>Magento is an open source e-commerce platform which has all the functionality to function from small to large online stores. Its architecture makes it possible to extend the functionalities with plugins where a lot of them are shared by the community. This is the reason why the platform is liked by developers and retailers.</p> <p>A practical developer guide packed with recipes that cover all the parts of Magento development. The recipes will start with the simple development exercises and get the more advanced as the book progresses. A good reference for every Magento developer!</p> <p>This book starts with the basics. The first thing is to create a test environment. Next, the architecture, tools, files and other basics are described to make you ready for the real work.</p> <p>The real work starts with the simple things like theming and catalog configuration. When you are familiar with this, we will move on to more complex features such as module and database development. When you have survived this, we will move on to the last part of making a shop ready for launch: performance optimization and testing. This book will guide you through all the development phases of Magento, covering the most common pitfalls through its recipes.</p>
Table of Contents (19 chapters)
Magento 1.8 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing Magento with sample data


When you install Magento, you can start with an empty database or a database with some sample products and configurations. For our development environment, the best approach is to start with the sample data because we can start using Magento directly after installation.

For a new webshop, it is recommended to start with an empty database and do the configuration yourself. To install Magento, we need the following data:

  • The Magento code

  • The sample data

Getting ready

You can download Magento and the sample data from Magento's website (http://www.magentocommerce.com/download). Download the latest Full release and the Sample data. The recipes of this book are based on the Magento Version 1.8.1.0. For the sample data, you can use the 1.6.1.0 Version.

How to do it...

The following steps show you how to install a clean Magento webshop with sample data:

  1. Extract the code in the appropriate folder of our web server. In our case, this is /var/www/magento-dev.local/public. Take a look at the folder structure by running the ls -la command in the site's root folder. We have to take care that the hidden files are included in the folder:

    ls -la
    drwxrwxr-x .
    drwxrwxr-x ..
    -rwxrw-r-- .htaccess
    -rw-rw-r-- .htaccess.sample
    -rw-rw-r-- api.php
    drwxrwxr-x app
    -rw-rw-r-- cron.php
    -rw-rw-r-- cron.sh
    drwxrwxr-x downloader
    drwxrwxr-x errors
    -rw-rw-r-- favicon.ico
    -rw-rw-r-- get.php
    -rw-rw-r-- .htaccess
    -rw-rw-r-- .htaccess.sample
    drwxrwxr-x includes
    -rw-rw-r-- index.php
    -rw-rw-r-- index.php.sample
    -rw-rw-r-- install.php
    drwxrwxr-x js
    drwxrwxr-x lib
    -rw-rw-r-- LICENSE_AFL.txt
    -rw-rw-r-- LICENSE.html
    -rw-rw-r-- LICENSE.txt
    -rw-rw-r-- mage
    drwxrwxr-x media
    -rw-rw-r-- php.ini.sample
    drwxrwxr-x pkginfo
    -rw-rw-r-- RELEASE_NOTES.txt
    drwxrwxr-x shell
    drwxrwxr-x skin
    drwxrwxr-x var

    Tip

    In Linux, hidden files or folders start wit a dot (.), such as the .htaccess file. The -a option of the ls command that we used shows all the files and folders, including the hidden ones. It is important to see that the .htaccess file is in the directory because this file contains the configuration for URL rewrites and other server configurations.

  2. When you extract the sample data archive, you see a media folder and a SQL file. The SQL file contains the database, the media folder, and the images. To install the media folder, merge this folder with the site's root media folder.

    Tip

    It is important to install the sample data before running the Magento install wizard. If Magento doesn't find the sample data in the database, the wizard continues with an empty database without the sample data.

  3. To install the database, you have to run the following commands:

    1. To create the database, run the following commands:

      mysql -u root -p
      create database magento_dev;
      exit;
      
    2. To import the SQL file, run the following commands:

      mysql -u <<username>> -p magento_dev < "path_to_sample_data.sql"
      

    Tip

    To avoid permission problems, ensure that all files and folders have the right permissions. For security reasons, it is recommended that all files have just enough permissions so that only the right users can access the right files. When you give all the rights (777), you don't have permission problems; but, every user on the server can read, write, and execute every file of your application.

  4. The next step is to run the Magento installation wizard. Go to the site's URL and the installer will be displayed as shown in the following screenshot:

  5. Continue with the installation process by accepting the terms and conditions.

  6. On the next screen, choose the correct language, locale, and currency for your store.

  7. On the Configuration page, fill the form with the right data:

    • Database Type: Enter MySQL in this field.

    • Host: Enter localhost in this field.

    • Database Name: Enter magento_dev (your Magento database name) in this field.

    • User Name: Enter root (your Magento database username) in this field.

    • User Password: Enter root (your database user password) in this field. It is possible to leave this empty.

    • Tables Prefix: Leave this field empty (if filled, all tables will have the prefix that is entered here).

    • Base URL: Enter http://magento-dev.local/ (the URL of your webshop) in this field.

    • Admin Path: Enter admin (the path to the backend) in this field.

    • Enable Charts: This check box must be checked.

    • Skip Base URL Validation Before the Next Step: This check box must be unchecked (if checked, the wizard will check for a valid URL when processing this form).

    • Use Web Server (Apache) Rewrites: This check box must be unchecked.

    • Use Secure URLs (SSL): This check box must be unchecked.

  8. Submit the form and continue to the next step. In this step, you can configure the admin account. Fill in the right data and remember the login and password, because this is required to manage the store. Leave the encryption key empty.

  9. After submitting this form, the installation wizard terminates. The setup is complete. You can now visit your store and enter the backend with the username that you have created in the installation wizard.

How it works...

We just created a fully functional Magento store. Technically, you can start selling products.

We have started with the sample data. The SQL file that we inserted in the database contains all the data for the sample webshop. When you want to create an empty shop, you can start with an empty database.

When installing a new shop, always follow the installer. The installer creates the app/etc/local.xml file and installs the values that you have set in the installer. These values are currency, timezone, backend user, and so on. The installer will show up when there is no local.xml file in the app/etc/ folder. In all other cases, the webshop will show up.

With a complete local.xml file in the app/etc folder, you can install Magento. However, this is not recommended because you don't have a backend user and the other configurations.