Chapter 4. Working with Data

Data is the heart of any application that needs to retain or manipulate information in any way. How to go about storing information in a database is generally a cause of consternation for developers building applications from scratch. The problem, you see, is that unlike any other part of a program, which can generally be used with little to no modification for other applications, databases must be tailored precisely to their specific application in order to be effective. You don’t need to worry about this though; it’s all taken care of already.

As you know, osCommerce sites use the MySQL Relational Database Management System to store information about products, customers, sessions, languages, configuration, orders, reviews, specials, and a bunch of other things. The structure of the database is created and built during the installation process and is ready to work whenever you decide to make changes. In fact, we have already been working with data because the configuration properties set in the last chapter are, of course, all retained by storing them in the database.

In this chapter, we are going to be working on adding, removing, and updating business-related information in the database. What type of information is this? Well, for a start, we need to learn how to add and remove customers, their orders, and most importantly, products to and from the database. Discussing how to add and remove products will take up the bulk of this chapter simply because it is more than likely the type of data you will work with most often.

It must be said—despite its apparent obviousness—that ensuring your data is accurate is just about the most important thing you can do, because corrupt data is worse than worthless, it’s actually detrimental. So, along the way, we will talk about the right approach to dealing with your information. This is important because, believe it or not, it is actually quite simple to produce data that is not accurate.

Specifically, in this chapter, we are going to talk about:

  • The preparations involved before adding products
  • Adding, removing, and updating data from the Catalog, Customers, and Reports sections in the administration tool
  • Viewing reports

Finally, it is important to realize that while it is essential that you understand how to use the administration tool effectively in order to build and maintain your site, it is not the be all and end all. You are encouraged to look for contributions such as EasyPopulate, or third-party tools like phpMyAdmin, which can help sort out your data problems in a more efficient manner than simply using the admin tool.

Preparing to Add Product Data

Many of you will already have a list, or at least a partial list, of all the products you intend to sell via your website. You may be an established business with a full catalog that you need to enter into your osCommerce site, or you could have a single product to begin with that you want to sell. Whatever your situation, there are certain things that you will need to get in order before you can create an online catalog that will actually promote the sale of your goods. So what are these things? Well, the best way to find out is to let osCommerce answer that.

Open up the administration tool to the Catalog section, choose the Categories/Products link and navigate all the way down till you reach a product, and click edit—it doesn’t matter which product for the moment. You will be presented with a screen that looks something like this:

Preparing to Add Product Data

Looking up and down this page you can see that there are a number of properties assigned to this product. Most are pretty intuitive to deal with; Products Status is easy enough to decide, and the Date Available also should not present you with too many difficulties. If you set the Date Available property to some time in the future, then a friendly note pops up on the product’s page on the website informing the customer that This product will be in stock on Friday 21 October, 2005 (or something similar depending on the date you set).

Of course, with the Out of Stock option set, the website will not show any product at all.

Products Manufacturer is an interesting attribute in the case of the demo site. We don’t want to list the manufacturers for our products, but we require the publishers to be listed. However, rather than redesigning the internals of osCommerce to represent this requirement, we can replace Manufacturer with Publisher in our mind’s eye and simply add publishers’ names to our list of manufacturers so that they can be displayed on the site as normal.

In order to add a manufacturer, you would simply go to the Manufacturers tab in the Catalog section and add one from there. All this will all be discussed in detail once we get to the Catalog section later in this chapter, so don’t worry about it for the moment.

Products name, Tax Class, Products Price (Net), Products Price (Gross), and Products Description are also pretty straightforward. Of course, you will need to research whatever special tax requirements you may be subject to before you go ahead and set that information. The default on the site, which is set in the Locations/Taxes section, is left for the time being since the product shown is not the one that the demo site will sell. We will deal with the tax options later on in Chapter 6. For now though, simply be aware that you will need to know where you stand with taxes in order to make the right choices when it comes to adding products.

Another interesting thing to note here is the fact that everything is, by default, given in three languages. If you think that you will need to include more than English into your site then obviously you will have to either hire someone to do the translations for you, or if you are a polyglot, you can simply copy out the product info into the language of your choice. Setting the languages you would like to use gets taken care of by the Localization section of the administration tool, and this will be dealt with in the chapter on customization. If you are only going to sell to a predominantly English‑speaking customer base, then simply leave the other language options blank.

Take a look at the Products Description text area on your own product page. You should notice that there are HTML formatting tags in this text. This is because osCommerce will render whatever you enter into this text area directly to the browser. Without adding the relevant HTML formatting you could be left with descriptions that aren’t nicely laid out—in this instance, the <br> tags simply give each sentence a new line.

Products Quantity is simple enough, and osCommerce will automatically reduce this when there are purchases if you have enabled stock control (see the previous chapter for more info on this). The Products Model gets displayed in the site’s navigation breadcrumb bar. So whatever you would like to show in the navigation bar is what you should enter here. For example, changing the model to Frantic_DVD will produce the following breadcrumb trail when viewed on the site. The Product Model is a very important value and you should ensure that it is never left blank and is always unique:

Preparing to Add Product Data

With that done, you can turn your attention to the Products Image and the Products URL. Now, we will be dealing with images in detail in the next chapter, so don’t fret too much about this. However, recall our earlier discussion about how osCommerce is laid out; because of the way things are set up, osCommerce automatically looks in the images folder under catalog for its images. It is recommended that you look at how the default image structure is laid out, and select one that will suit your store (there will be recommendations made in the following chapter).

Setting the Products URL will give customers the option to visit the product maker’s website while viewing the product information in your store. Leaving this blank will simply cause the option not to be presented. Finally, Products Weight is easy enough to deal with, given suitable scales to measure it with.

Now that you have a good idea of what information you need to gather on each of your products and how to categorize them, we can begin adding to the store.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.167.183