Unless you??™re a
PHP guru already, you should feel really proud of creating successfully a functional product
catalog that features paging, categories and departments, product details pages, and many
more smaller but equally important features!
Chapter 6 will be at least as exciting as this one, because you??™ll learn how to add attributes
to products in your web site!
CHAPTER 5 ?– CREATING THE PRODUCT CATALOG: PART 2 174
Product Attributes
Many online stores allow shoppers to customize the products they buy. For example, when
selling t-shirts, it??™s common to let your customer choose the size and color of the t-shirt??”
sparing them the fashion risk of one-size-one-color-fits-all. In this chapter, we??™ll implement
the product attributes feature in TShirtShop (see Figure 6-1).
Figure 6-1. Products with attributes
175
C H A P T E R 6
We??™ll do this starting with the data tier, where you??™ll create data tables and a stored procedure,
then write the business tier code that calls that procedure, and finally use this functionality to
update the Smarty template for the user interface. At the end of this chapter, our catalog will
allow customers to choose the size and color of the t-shirt, as shown in Figure 6-1. Since the
attributes data is stored in the database, you can add your own attributes and attribute values.
Implementing the Data Tier
The data tier components that support the product attributes feature include three data tables
(attribute, attribute_value, and product_attribute) and a stored procedure named catalog_
get_product_attributes.
Pages:
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275