g '1' from 'submit_edit_prod_1' */
$this->_mActionedProductId = (int)substr($key, $last_underscore + 1);
break;
}
CHAPTER 11 ?– CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 323
$this->mLinkToDepartmentCategoriesAdmin =
Link::ToDepartmentCategoriesAdmin($this->mDepartmentId);
$this->mLinkToCategoryProductsAdmin =
Link::ToCategoryProductsAdmin($this->mDepartmentId, $this->mCategoryId);
}
public function init()
{
// If adding a new product ...
if ($this->_mAction == 'add_prod')
{
$product_name = $_POST['product_name'];
$product_description = $_POST['product_description'];
$product_price = $_POST['product_price'];
if ($product_name == null)
$this->mErrorMessage = 'Product name is empty';
if ($product_description == null)
$this->mErrorMessage = 'Product description is empty';
if ($product_price == null || !is_numeric($product_price))
$this->mErrorMessage = 'Product price must be a number!';
if ($this->mErrorMessage == null)
{
Catalog::AddProductToCategory($this->mCategoryId, $product_name,
$product_description, $product_price);
header('Location: ' .
htmlspecialchars_decode(
$this->mLinkToCategoryProductsAdmin));
}
}
// If we want to see a product details
if ($this->_mAction == 'edit_prod')
{
header('Location: ' .
htmlspecialchars_decode(
Link::ToProductAdmin($this->mDepartmentId,
$this->mCategoryId,
$this->_mActionedProductId)));
exit();
}
CHAPTER 11 ?– CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 324
$this->mProducts = Catalog::GetCategoryProducts($this->mCategoryId);
$this->mProductsCount = count($this->mProducts);
}
}
?>
3.
Pages:
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438