本文整理汇总了PHP中Products::createProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::createProduct方法的具体用法?PHP Products::createProduct怎么用?PHP Products::createProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::createProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate()
{
self::validateAdmin();
$platformList = Platform::getPlatformListByAdmin();
$genreList = Genre::getGenresListByAdmin();
if (isset($_POST['submit'])) {
$option['code'] = $_POST['code'];
$option['name'] = $_POST['name'];
$option['price'] = $_POST['price'];
$option['platform_id'] = $_POST['platform_id'];
$option['genre_id'] = $_POST['genre_id'];
$option['brand'] = $_POST['brand'];
$option['description'] = $_POST['description'];
$option['availability'] = $_POST['availability'];
$option['is_recomend'] = $_POST['is_recomend'];
$option['is_new'] = $_POST['is_new'];
$option['status'] = $_POST['status'];
$errors = false;
if (!isset($option['name']) || empty($option['name'])) {
$errors[] = "Введите имя товара";
print_r($errors);
}
if ($errors == false) {
$id = Products::createProduct($option);
if ($id) {
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
move_uploaded_file($_FILES['image']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . "/upload/images/products/(" . $id . ").png");
}
}
header("Location: /evkazolinAdminka/product/");
}
}
require_once ROOT . '/views/admin_product/create.php';
return true;
}
示例2: actionSpec
/**
* 商品规格
*/
public function actionSpec()
{
$goods_id = $this->get('goods_id');
$goods_row = Goods::model()->find('goods_id = :goods_id', array(':goods_id' => $goods_id));
if ($_POST) {
$product_attributes = $this->post('Product');
$Product = new Products();
$result = $Product->createProduct($goods_id, $goods_row, $product_attributes);
if ($result) {
$this->message('success', '编辑成功', $this->createUrl('index'));
} else {
$this->message('error', '编辑失败', $this->createUrl('index'));
}
}
//商品规格
$GoodsTypeSpec = new GoodsTypeSpec();
$items = $GoodsTypeSpec->TypeSpecValue($goods_row['type_id']);
$spec_list_t = $GoodsTypeSpec->ProductSpecList($goods_id);
$spec_list = array();
foreach ($spec_list_t as $v) {
$spec_list[$v['spec_id']] = $v;
}
//货品列表
$product_list = Products::model()->findAll('goods_id = :goods_id AND spec_desc <> :spec_desc AND disabled = :disabled', array(':goods_id' => $goods_id, ':spec_desc' => '', ':disabled' => 'false'));
echo $this->render('spec', array('items' => $items, 'spec_list' => $spec_list, 'goods_row' => $goods_row, 'product_list' => $product_list));
}