Tuesday, February 22, 2011

ZenCart 1.3.9 - Template Problem

ISSUE:

After working to create a custom theme I found the default template and any new templates became unavailable through the typical method within the admin console.  I attempted to resolve the issue by re-installing and stepping through each modification systematically with no success.  This led to the manual modification of the database to choose the theme of choice.

WORK AROUND:
  • Obtain the database name, database username and password.
  • Create a new template being sure to include a template_info.php with the correct information.  Note the directory name.
  • Enter MySQL (-p will prompt for the user password)
       # mysql -u database_username -p
  •  Select database to use.
       mysql> use database_name;
  • Change the default template dir.
       mysql> UPDATE database_template_select SET template_dir = 'new_template'; 
  • Exit database
       mysql> \q
Template directory has now been changed and will be reflected in the admin console.

Monday, February 14, 2011

ZenCart - MySQL Database Backup & Restore (mirror really)

While there seems to be a tremendous amount of information on MYSQL and backing up databases as well as restoring them, I ran into some challenges and had to follow the steps below to mirror a database.

My goal was to simply have the ability to backup my database while going through some testing.  I also wanted to verify that once I had a working "development" environment that I could export/import into a new "production" environment.  While mysqldump should accomodate this request possibly in one simple command, I had issues and ended up using mysqldump to export and the "source" command to populate a new database.  

# mysqldump -u user_name -p database_name > database_bkup_file_name.sql

Note:  Adding the '-p' will cause mysqldump to prompt for the password for the user that you stated in "user_name".

You should theoretically then be able to use mysqldump to then populate a database as follows:

# mysqldump -u user_name -p database_name < database_bkup_file_name.sql

Based on some challenges and a desire to move forward and not necessarily become a MySQL admin, I simply created a new database, added the proper user & permissions followed by:

mysql> use new_database_name;

mysql> source name_of_database_backup_file.sql;
 
It should have been obvious that the new database was being populated but if you desire to verify, you can simply view the tables.

mysql> show tables;

While this proved handy, it does not allow you to update a database.  I will be making some incremental changes to a "dev" environment and will want to update the "prod" environment.  In order to accomplish this, I will need to drop the "prod" database and then recreate it and populate it with data.  I can see how learning to properly use the mysqlimport command may be the better answer.