Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Magento 2 Development Cookbook

You're reading from   Magento 2 Development Cookbook Over 60 recipes that will tailor and customize your experience with Magento 2

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785882197
Length 304 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface 1. Upgrading from Magento 1 FREE CHAPTER 2. Working with Products 3. Theming 4. Creating a Module 5. Databases and Modules 6. Magento Backend 7. Event Handlers and Cronjobs 8. Creating a Shipping Module 9. Creating a Product Slider Widget 10. Performance Optimization 11. Debugging and Unit Testing Index

Creating a Magento 1 website with sample data

To start a Magento 2 upgrade, we need a Magento 1 webshop with some data. In this recipe, we will install the latest Magento version, 1.9, with the sample data for the new responsive theme.

Getting ready

To install a Magento 1 website, we need the following stuff:

  • A web server (Linux, Apache2, PHP, or MySQL)
  • The Magento 1.9 codebase
  • The Magento 1.9 sample data

Note

The Magento 1.9 codebase and sample data can be downloaded from the Magento site at http://www.magentocommerce.com/download.

The following stuff is recommended for the installation:

  • Command-line access
  • A virtual host (domain name) that is going to be your web root

Note

We recommend that you use a test server that is on your development machine. If you use a Linux or a Mac operating system, you can install the webserver on your local machine. If you have a Windows machine, you can use a virtual Linux server for your development.

How to do it...

  1. Extract the Magento code archive in your webroot (the directory of the virtualhost). An ls -la command should give you the following output:
    api.php
    app
    cron.php
    cron.sh
    downloader
    errors
    favicon.ico
    get.php
    includes
    index.php
    index.php.sample
    install.php
    js
    lib
    LICENSE_AFL.txt
    LICENSE.html
    LICENSE.txt
    mage
    media
    php.ini.sample
    pkginfo
    RELEASE_NOTES.txt
    shell
    skin
    var
    
  2. Extract the sample data archive to a different folder from the webroot. Copy the contents of the media and skin folders to the media and skin folders in your webroot. We can do this by using the following cp command:
    cp –R <path_to_sampledata_folder>/media/* <path_to_magento_folder>/media/
    cp –R <path_to_sampledata_folder/skin/* <path_to_magento_folder>/skin/
    
  3. Create a database for the Magento 1 installation and name it magento1. We can do this by running the following commands:
    mysql -u <username> -p
    create database magento1;
    exit;
    
  4. Import the sql file that is in the sample data directory. This file contains a database that we will import into the magento1 database. We can do this by running the following command:
    mysql -u <username> -p magento1< "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 because each user can read, write and, execute each file of your application. More information about file permissions can be found at http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html.

  5. When the files are in the right place and the database is imported, we can run the Magento installer. Open your browser and go to the domain that is configured for your website. You should see the installer as in the following screenshot:
    How to do it...
  6. Continue with the installation process by accepting the terms and conditions.
  7. On the next screen, choose the correct language, locale, and currency for your store.
  8. On the configuration page, fill in the form with the right data:
    • Database Type: MySQL.
    • Host: Enter the hostname or IP address of your database server (localhost if it is on the same machine).
    • Database name: Enter magento1 in this field (or another name if you have a different name for your database).
    • User name: Enter your database username.
    • User password: Enter your database password.
    • Tables prefix: Leave this field empty (the string in this field will be used to prefix all tables of your database).
    • Base URL: Enter the URL of your website in this field.
    • Admin path: Enter admin in this field. This will be the path of the backend.
    • Enable charts: For development, it is recommended that this be unchecked.
    • Skip Base URL Validation Before the Next Step: When checked, the wizard will check for a valid URL when processing this form.
    • Use Web Server (Apache) rewrites: Check this when the apache module mod_rewrite is enabled.
    • Use Secure URL's (SSL): This checkbox must be unchecked if you don't use HTTPS.
  9. Submit this form and we will be forwarded to the next step. In this step, you can configure the administrator account. Fill in the right data and remember the username and password because this is required to manage the store. Leave the encryption key field empty.
  10. After submitting this form, the installation is complete. Optionally, you can submit the Magento survey. At the bottom of the page, there are buttons to navigate to the frontend and backend. When going to the frontend, you can see a demo shop with sample data as in the following screenshot:
    How to do it...
  11. The layout is responsive. When scaling your browser to a smaller width, the website will switch to the mobile layout like in the following screenshot:
    How to do it...

How it works…

We have just created a fully functional Magento 1 store. The webshop is fully configured and filled with data about products, customers, and orders, just the data we need to migrate to Magento 2 (in the upcoming recipes).

When installing a new shop, you have to follow the installer. This interface creates a configuration file app/etc/local.xml. If the file doesn't exist, Magento will launch the installer wizard. If the file is there, Magento will run the shop.

With a valid local.xml file, it is technically possible to install a new Magento shop, but this is not recommended because some settings such as a backend user, time zone, and currency are not set. These are actions that you have to do manually when choosing for this method.

You have been reading a chapter from
Magento 2 Development Cookbook
Published in: Dec 2015
Publisher:
ISBN-13: 9781785882197
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime