Prev | Current Page 427 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

Open the presentation/link.php file, and add the following method at the end of the Link class:
// Create link to a products administration page
public static function ToCategoryProductsAdmin($departmentId, $categoryId)
{
$link = 'Page=Products&DepartmentId=' . $departmentId .
'&CategoryId=' . $categoryId;
return self::ToAdmin($link);
}
4. Modify the init() method of the StoreAdmin class in store_admin.php to load the admin_products
componentized template:
// Choose what admin page to load ...
if ($admin_page == 'Departments')
$this->mContentsCell = 'admin_departments.tpl';
elseif ($admin_page == 'Categories')
$this->mContentsCell = 'admin_categories.tpl';
elseif ($admin_page == 'Attributes')
$this->mContentsCell = 'admin_attributes.tpl';
elseif ($admin_page == 'AttributeValues')
$this->mContentsCell = 'admin_attribute_values.tpl';
elseif ($admin_page == 'Products')
$this->mContentsCell = 'admin_products.tpl';
5. Add the following business tier code to the Catalog class inside of business/catalog.php:
// Gets products in a category
public static function GetCategoryProducts($categoryId)
{
// Build the SQL query
$sql = 'CALL catalog_get_category_products(:category_id)';
// Build the parameters array
$params = array (':category_id' => $categoryId);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
// Creates a product and assigns it to a category
public static function AddProductToCategory($categoryId, $productName,
$productDescription, $productPrice)
CHAPTER 11 ?–  CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 325
{
// Build the SQL query
$sql = 'CALL catalog_add_product_to_category(:category_id, :product_name,
:product_description, :product_price)';
// Build the parameters array
$params = array (':category_id' => $categoryId,
':product_name' => $productName,
':product_description' => $productDescription,
':product_price' => $productPrice);
// Execute the query
DatabaseHandler::Execute($sql, $params);
}
6.


Pages:
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
drukarki fiskalne kraków willa karmazyn międzyzdroje www.books61.hobbitstory.com terapia magnetyczna Informacje o hostingu