Example #1
0
?>
jquery/plugins/ajaxfileupload/jquery.ajaxfileupload.js"></script>
<script type="text/javascript" src="<?php 
echo $_tmconfig['tm_js_dir'];
?>
fileuploader.js"></script>
<script type="text/javascript" src="<?php 
echo $_tmconfig['tm_js_dir'];
?>
jquery/jquery.tablednd_0_5.js"></script>
<!--//head-->
<div class="col-md-12">
<?php 
if (isset($_POST['sveProduct']) && Tools::getRequest('sveProduct') == 'add') {
    $product = new Product();
    $product->copyFromPost();
    if ($product->add()) {
        if (!$product->updateCategories($_POST['categoryBox']) or !$product->addToTags($_POST['tags']) or !$product->updateAttribute($_POST['attribute_items'])) {
            $product->_errors = '添加产品内容时发生了一个错误';
        }
    }
    if (is_array($product->_errors) and count($product->_errors) > 0) {
        $errors = $product->_errors;
    } else {
        $_GET['id'] = $product->id;
        echo '<div class="conf">添加产品成功</div>';
    }
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new Product($id);
Example #2
0
 public function loadProduct($id_category, $fields)
 {
     $product = new Product();
     $product->copyFromPost();
     $product->id_category_default = (int) end($id_category);
     $product->id_brand = (int) $fields['id_brand'];
     $product->price = (double) $fields['price'];
     $product->special_price = (double) $fields['old_price'];
     $product->ean13 = pSQL($fields['ean13']);
     $product->weight = 1;
     $product->in_stock = 1;
     $product->quantity = (double) $fields['quantity'];
     $product->name = pSQL($fields['name']);
     $product->rewrite = pSQL(preg_replace("/[^-0-9a-zA-Z]+/", "", str_replace(' ', '-', trim($fields['name']))));
     $product->description = pSQL($fields['description'], true);
     $product->active = 1;
     if ($product->add()) {
         $product->updateCategories($id_category);
         return (int) $product->id;
     } else {
         print_r($product->_errors);
     }
 }