product_id = pc.product_id
WHERE pc.category_id = inCategoryId
INTO productCategoryRowsCount;
IF productCategoryRowsCount = 0 THEN
DELETE FROM category WHERE category_id = inCategoryId;
SELECT 1;
ELSE
SELECT -1;
END IF;
END$$
7. Load admin.php in your browser, choose a department, and click its Edit Categories button. The categories
componentized template should load, displaying a page like the one shown in Figure 10-4. Editing the categories
should work as shown in Figure 10-10.
How It Works: Administering Categories
The code for managing categories follows the same patterns as the code for managing departments. In short, you
completed these tasks:
??? You created the admin_categories Smarty componentized template, which is made of two pieces: the
template (admin_categories.tpl) and its associated presentation object (admin_categories.php).
These two files implement the presentation tier of the categories administration feature.
??? You updated the store_admin Smarty componentized template (more specifically, its presentation object)
to load the admin_categories template when a category is selected. As you know from the beginning of
the chapter, store_admin is the componentized template loaded by admin.php; its role is to decide what
administration template to load.
CHAPTER 10 ?– CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 303
??? You created the business tier methods that support the necessary category administration features: adding,
editing, and removing categories.
Pages:
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422