예제 #1
0
 public function initWithProductInfo(ProductInfo $productInfo)
 {
     $this->id = $productInfo->id;
     $this->name = $productInfo->name;
     $this->description = $productInfo->description;
     $this->setImageUrl($productInfo->getRawImageUrl());
     $this->price = $productInfo->price;
     $this->category = $productInfo->category;
     $this->sizes = $productInfo->sizes;
 }
/**
 * _entity_create_node
 */
function _entity_update_node($nid = NULL, $node_type = NULL, $depend_chassis)
{
    $type = NULL;
    $depend_chassis_boolean = FALSE;
    switch ($node_type) {
        case 'U':
            $type = 'chassis';
            break;
        case 'C':
            $type = 'card';
            $depend_chassis_boolean = TRUE;
            break;
        case 'S':
            $type = 'software';
            $depend_chassis_boolean = TRUE;
            break;
        default:
            break;
    }
    $node = node_load($nid);
    $node_wrapper = entity_metadata_wrapper('node', $node);
    if ($depend_chassis_boolean) {
        if ($depend_chassis) {
            $ProductInfo = new ProductInfo($nid);
            $old_depend_chassis = $ProductInfo->dependChassisTids();
            if (is_array($old_depend_chassis)) {
                $new_depend_chassis = array_unique(array_merge($depend_chassis, $old_depend_chassis));
            } else {
                $new_depend_chassis = $depend_chassis;
            }
            $node_wrapper->field_product_depend_chassis->set($new_depend_chassis);
        }
    }
    $node_wrapper->save();
    dpm($nid . ' add ' . $depend_chassis);
}
예제 #3
0
 public function getProductById($id)
 {
     $query = "SELECT p.id as pid, p.name, p.description, p.image_url, \n            p.price, c.id as cid, c.name as cat_name, s.id as sid, s.value as size\n            FROM products p, categories c, sizes s, products_sizes ps \n            WHERE p.id = ps.pid AND s.id = ps.sid AND p.category = c.id AND p.id={$id}";
     $this->connectDb();
     $result = mysql_query($query);
     while ($row = mysql_fetch_array($result)) {
         if (isset($product) == false) {
             $product = new ProductInfo();
             $product->id = $row["pid"];
             $product->name = $row["name"];
             $product->description = $row["description"];
             $product->setImageUrl($row["image_url"]);
             $product->price = $row["price"];
             $category = new ProductCategory();
             $category->id = $row["cid"];
             $category->name = $row["cat_name"];
             $product->category = $category;
         }
         $size = new ProductSize();
         $size->id = $row["sid"];
         $size->value = $row["size"];
         $product->sizes[$size->id] = $size;
     }
     $this->disconnectDb();
     return $product;
 }
예제 #4
0
    echo $size->value;
    ?>
</option>
                <?php 
}
?>
            </select>
            
            <div class="lbls">Цена:</div><input required name="fPrice" type="text" placeholder="цена..." id="in_price" /> 
            
            <input name="addItem" type="image" src="/images/admin_additem.png" />
            
            <?php 
if (isset($_POST['addItem_x'])) {
    unset($_POST['addItem_x']);
    $product = new ProductInfo();
    if (is_uploaded_file($_FILES["foto"]["tmp_name"])) {
        $upfile = getcwd() . "\\images\\items\\" . basename($_FILES["foto"]["name"]);
        $product->setImageUrl($_FILES["foto"]["name"]);
        move_uploaded_file($_FILES["foto"]["tmp_name"], $upfile);
    } else {
        echo "Error =(";
    }
    if (is_uploaded_file($_FILES["prefoto"]["tmp_name"])) {
        $upfile = getcwd() . "\\images\\items\\preview_" . basename($_FILES["prefoto"]["name"]);
        move_uploaded_file($_FILES["prefoto"]["tmp_name"], $upfile);
    } else {
        echo "Error =(";
    }
    $product->name = $_POST['fName'];
    $product->category = categoryById($cats, $_POST['fCat']);