当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::delete方法代码示例

本文整理汇总了PHP中Product::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::delete方法的具体用法?PHP Product::delete怎么用?PHP Product::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEmptyOpportunityGetsCreatedOnProductEdit

 /**
  * Shows a bug with opportunity as a product relation. The bug is when there is a default customField value
  * The fix is the use of isReallyModified() to now determine if during save() if the model has really been modified
  * If it is a new model, then for example 'name' must not be empty, otherwise it is has not really been modified
  */
 public function testEmptyOpportunityGetsCreatedOnProductEdit()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $name = 'Amazing Kid Sample';
     $productTemplateName = ProductsDemoDataMaker::getProductTemplateForProduct($name);
     $productTemplate = ProductTemplateTestHelper::createProductTemplateByName($productTemplateName);
     $model = new Product();
     $name = 'My Simple Product';
     $model->name = $name;
     $model->quantity = 4;
     $model->stage->value = 'Open';
     $model->priceFrequency = $productTemplate->priceFrequency;
     $model->sellPrice->value = $productTemplate->sellPrice->value;
     $model->type = $productTemplate->type;
     $postData = array();
     $postData['opportunity'] = array('id' => '');
     $model->setAttributes($postData);
     $model->validate();
     $sanitizedOwnerData = array('owner' => array('id' => $super->id));
     $model->setAttributes($sanitizedOwnerData);
     $model->validate(array('owner'));
     $this->assertTrue($model->opportunity->id < 0);
     //need to check this to call get first.
     $this->assertTrue($model->save(false));
     $this->assertTrue($model->save(false));
     $this->assertTrue($model->opportunity->id < 0);
     $model->delete();
     $productTemplate->delete();
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:35,代码来源:ProductTest.php

示例2: post

 public function post()
 {
     $post = Input::all();
     $validator = Product::validate($post);
     $productId = $post['id'];
     if ($validator->fails()) {
         return Redirect::to('productos/' . $productId)->withErrors($validator)->withInput();
     } else {
         $product = self::__checkExistence($productId);
         $isNew = false;
         if (!$productId) {
             $product = new Product();
             $isNew = true;
         }
         $product->name = $post['name'];
         $product->description = $post['description'];
         $product->code = $post['code'];
         $product->minimum_stock = $post['minimum_stock'];
         $product->cost = str_replace(',', '.', $post['cost']);
         $product->save();
         if ($isNew) {
             Globals::triggerAlerts(4, array('productId' => $product->id));
         }
         if ($post['status'] == 'inactive') {
             $product->delete();
         } else {
             if ($product->trashed()) {
                 $product->restore();
             }
         }
         Session::flash('success', 'Producto guardado correctamente.');
         return Redirect::to('productos');
     }
 }
开发者ID:frankpaul142,项目名称:cloudinventory,代码行数:34,代码来源:ProductController.php

示例3: deleteProduct

 public function deleteProduct($idP, $ref)
 {
     $product = new Product($idP);
     $product->delete();
     self::deleteAttributePdt($ref);
     Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'ec_ecopresto_product_shop` SET `imported`=2 WHERE `reference`="' . pSQL($ref) . '" AND `id_shop`=' . (int) self::getInfoEco('ID_SHOP'));
     if (Db::getInstance()->execute('SELECT `reference` FROM `' . _DB_PREFIX_ . 'ec_ecopresto_product_deleted` WHERE `reference`="' . pSQL($ref) . '"')) {
         Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'ec_ecopresto_product_deleted` SET status=1 WHERE `reference`="' . pSQL($ref) . '"');
     }
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:10,代码来源:importProduct.class.php

示例4: delete

 function delete($id = false)
 {
     if ($id) {
         $product = new Product($id);
         if ($product->exists()) {
             $product->delete();
         }
     }
     $this->session->set_flashdata('top_success', 'Продукт удален');
     redirect('admin/products/show');
 }
开发者ID:usaphp,项目名称:listafe,代码行数:11,代码来源:products.php

示例5:

 function admin_delete_product($id = null)
 {
     if (!$id) {
         $this->Session->setFlash('Invalid id for a product');
         $this->redirect(array('action' => 'admin_show_all_products'));
     }
     if ($this->Product->delete($id)) {
         $this->Session->setFlash('Product was deleted successfully!');
         $this->redirect(array('action' => 'admin_show_all_products'));
     }
     $this->Session->setFlash('Product was not deleted!');
     $this->redirect(array('action' => 'admin_show_all_products'));
 }
开发者ID:johnulist,项目名称:ecommerce,代码行数:13,代码来源:products_controller.php

示例6: delete

 /**
  * Delete product
  * 
  * @param   int     $id   Product ID
  * @return  array
  *
  * @url	DELETE product/{id}
  */
 function delete($id)
 {
     if (!DolibarrApiAccess::$user->rights->product->supprimer) {
         throw new RestException(401);
     }
     $result = $this->product->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Product not found');
     }
     if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     return $this->product->delete($id);
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:22,代码来源:api_product.class.php

示例7: deleteAction

 function deleteAction()
 {
     $this->view->title = "Delete Product";
     if ($this->_request->isPost()) {
         $id = (int) $this->_request->getPost('id');
         $del = $this->_request->getPost('del');
         if ($del == 'Yes' && $id > 0) {
             $products = new Product();
             $where = 'id=' . $id;
             $products->delete($where);
         }
         $this->_redirect('/');
     } else {
         $id = (int) $this->_request->getParam('id');
         if ($id > 0) {
             $product = new Product();
             $this->view->product = $product->fetchRow('id=' . $id);
         }
     }
 }
开发者ID:ashikkalavadiya,项目名称:zendapp,代码行数:20,代码来源:IndexController.php

示例8: truncateTables

 private function truncateTables($case)
 {
     switch ((int) $case) {
         case $this->entities[$this->l('Categories')]:
             $categories = Db::getInstance()->ExecuteS('SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category` WHERE id_category != 1');
             foreach ($categories as $category) {
                 $c = new Category((int) $category['id_category']);
                 $c->delete();
             }
             break;
         case $this->entities[$this->l('Products')]:
             $products = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product`');
             foreach ($products as $product) {
                 $p = new Product((int) $product['id_product']);
                 $p->delete(true);
             }
             break;
         case $this->entities[$this->l('Customers')]:
             $customers = Db::getInstance()->ExecuteS('SELECT `id_customer` FROM `' . _DB_PREFIX_ . 'customer`');
             foreach ($customers as $customer) {
                 $c = new Customer((int) $customer['id_customer']);
                 $c->delete();
             }
             break;
         case $this->entities[$this->l('Addresses')]:
             $addresses = Db::getInstance()->ExecuteS('SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address`');
             foreach ($addresses as $address) {
                 $a = new Address((int) $address['id_address']);
                 $a->delete();
             }
             break;
         case $this->entities[$this->l('Combinations')]:
             $products = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product`');
             foreach ($products as $product) {
                 $p = new Product((int) $product['id_product']);
                 $p->deleteProductAttributes();
             }
             break;
         case $this->entities[$this->l('Manufacturers')]:
             $manufacturers = Db::getInstance()->ExecuteS('SELECT `id_manufacturer` FROM `' . _DB_PREFIX_ . 'manufacturer`');
             foreach ($manufacturers as $manufacturer) {
                 $m = new Manufacturer((int) $manufacturer['id_manufacturer']);
                 $m->delete();
             }
             break;
         case $this->entities[$this->l('Suppliers')]:
             $suppliers = Db::getInstance()->ExecuteS('SELECT `id_supplier` FROM `' . _DB_PREFIX_ . 'supplier`');
             foreach ($suppliers as $supplier) {
                 $m = new Supplier((int) $supplier['id_supplier']);
                 $m->delete();
             }
             break;
     }
     Image::clearTmpDir();
     return true;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:56,代码来源:AdminImport.php

示例9: admin

 function admin()
 {
     global $Shopp;
     $db =& DB::get();
     if (!defined('WP_ADMIN') || !isset($_GET['page'])) {
         return;
     }
     $Admin = $Shopp->Flow->Admin;
     $adminurl = $Shopp->wpadminurl . "admin.php";
     $defaults = array('page' => false, 'deleting' => false, 'delete' => false, 'id' => false, 'save' => false, 'duplicate' => false, 'next' => false);
     $args = array_merge($defaults, $_REQUEST);
     extract($args, EXTR_SKIP);
     if (strstr($page, $Admin->categories)) {
         if ($page == "shopp-categories" && !empty($deleting) && !empty($delete) && is_array($delete)) {
             foreach ($delete as $deletion) {
                 $Category = new Category($deletion);
                 $db->query("UPDATE {$Category->_table} SET parent=0 WHERE parent={$Category->id}");
                 $Category->delete();
             }
             $redirect = esc_url(add_query_arg(array_merge($_GET, array('delete[]' => null, 'deleting' => null)), $adminurl));
             shopp_redirect($redirect);
         }
         if ($id && $id != "new") {
             $Shopp->Category = new Category($id);
         } else {
             $Shopp->Category = new Category();
         }
         if ($save) {
             $this->save_category($Shopp->Category);
             $this->Notice = '<strong>' . stripslashes($Shopp->Category->name) . '</strong> ' . __('has been saved.', 'Shopp');
             if ($next) {
                 if ($next != "new") {
                     $Shopp->Category = new Category($next);
                 } else {
                     $Shopp->Category = new Category();
                 }
             } else {
                 if (empty($id)) {
                     $id = $Shopp->Category->id;
                 }
                 $Shopp->Category = new Category($id);
             }
         }
     }
     // end $Admin->categories
     if (strstr($page, $Admin->products)) {
         if ($page == "shopp-products" && !empty($deleting) && !empty($delete) && is_array($delete)) {
             foreach ($delete as $deletion) {
                 $Product = new Product($deletion);
                 $Product->delete();
             }
             $redirect = esc_url(add_query_arg(array_merge($_GET, array('delete' => null, 'deleting' => null)), $adminurl));
             shopp_redirect($redirect);
             exit;
         }
         if ($duplicate) {
             $Product = new Product();
             $Product->load($duplicate);
             $Product->duplicate();
             shopp_redirect(add_query_arg('page', $Admin->products, $adminurl));
         }
         if ($id && $id != "new") {
             $Shopp->Product = new Product($id);
             $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags'));
         } else {
             $Shopp->Product = new Product();
             $Shopp->Product->published = "on";
         }
         if ($save) {
             $this->save_product($Shopp->Product);
             $this->Notice = '<strong>' . stripslashes($Shopp->Product->name) . '</strong> ' . __('has been saved.', 'Shopp');
             if ($next) {
                 if ($next == "new") {
                     $Shopp->Product = new Product();
                     $Shopp->Product->published = "on";
                 } else {
                     $Shopp->Product = new Product($next);
                     $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags'));
                 }
             } else {
                 if (empty($id)) {
                     $id = $Shopp->Product->id;
                 }
                 $Shopp->Product = new Product($id);
                 $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags'));
             }
         }
     }
     // end $Admin->products
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:90,代码来源:Flow.php

示例10: Product

			dol_print_error($product->db);
		}
	}
}

/*
 * Suppression d'un produit/service pas encore affect
 */
if ($action == 'confirm_delete' && $confirm == 'yes')
{
	$product = new Product($db);
	$product->fetch($id);

	if ( ($product->type == 0 && $user->rights->produit->supprimer)	|| ($product->type == 1 && $user->rights->service->supprimer) )
	{
		$result = $product->delete($id);
	}

	if ($result == 0)
	{
		Header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.$product->ref);
		exit;
	}
	else
	{
		$reload = 0;
		$action='';
	}
}

开发者ID:remyyounes,项目名称:dolibarr,代码行数:29,代码来源:fiche.php

示例11: testProductDelete

 /**
  * testProductDelete
  *
  * @param       int $id     Id of product
  * @return      void
  *
  * @depends testProductOther
  * The depends says test is run only if previous is ok
  */
 public function testProductDelete($id)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Product($this->savdb);
     $result = $localobject->fetch($id);
     $result = $localobject->delete($id);
     print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $result;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:23,代码来源:ProductTest.php

示例12: array

        //var_dump($subs);
        break;
    case 'selectProduct':
        $name = $_GET['name'];
        $id = $_GET['id'];
        $proObj = $pro->product($name, $id);
        if ($proObj) {
            $result = array("result" => "false");
        } else {
            $result = array("result" => "true");
        }
        echo json_encode($result);
        //var_dump($proObj);
        break;
    case 'editstatus':
        $id = $_GET['id'];
        $status = $_GET['status'];
        //echo "id = ".$id."status = ".$status;
        $pro->status = $status;
        $product_id = $pro->updateStatus($id);
        echo $product_id;
        $_SESSION['Psuccess'] = "Product add has updated  success";
        header('location:../controle.php#tabs-5');
        //echo " error on update";
        break;
    case 'delete':
        $id = $_GET['id'];
        echo $pro->delete($id);
        header('location:../controle.php#tabs-5');
        break;
}
开发者ID:ElsayedAhmed,项目名称:php-proj,代码行数:31,代码来源:product-server.php

示例13: connectToEncryptedMySQL

<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "product.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini");
$product = new Product(null, "imagefile", 10, "Info", "Detail", "Tech", "Name");
$product->insert($pdo);
$product->setProductName("This is the new name");
$product->update($pdo);
$product->delete($pdo);
开发者ID:jfindley2,项目名称:amazon-product,代码行数:10,代码来源:product-shakedown.php

示例14: postProcess

    public function postProcess($token = NULL)
    {
        global $currentIndex;
        /* Add a new product */
        if (Tools::isSubmit('submitAddproduct') or Tools::isSubmit('submitAddproductAndStay')) {
            if ($this->tabAccess['add'] === '1') {
                $this->submitAddproduct($token);
            } elseif (Tools::getValue('id_product') and $this->tabAccess['edit'] === '1') {
                $this->submitAddproduct($token);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
            }
        }
        /* Delete a product in the download folder */
        if (Tools::getValue('deleteVirtualProduct')) {
            if ($this->tabAccess['delete'] === '1') {
                $this->deleteVirtualProduct();
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to delete anything here.');
            }
        } elseif (Tools::isSubmit('submitAttachments')) {
            if ($this->tabAccess['edit'] === '1') {
                if ($id = intval(Tools::getValue($this->identifier))) {
                    if (Attachment::attachToProduct($id, $_POST['attachments'])) {
                        Tools::redirectAdmin($currentIndex . '&id_product=' . $id . '&conf=4&add' . $this->table . '&tabs=6&token=' . ($token ? $token : $this->token));
                    }
                }
            }
        } elseif (isset($_GET['duplicate' . $this->table])) {
            if ($this->tabAccess['add'] === '1') {
                if (Validate::isLoadedObject($product = new Product(intval(Tools::getValue('id_product'))))) {
                    $id_product_old = $product->id;
                    unset($product->id);
                    unset($product->id_product);
                    $product->indexed = 0;
                    if ($product->add() and Category::duplicateProductCategories($id_product_old, $product->id) and ($combinationImages = Product::duplicateAttributes($id_product_old, $product->id)) !== false and Product::duplicateAccessories($id_product_old, $product->id) and Product::duplicateFeatures($id_product_old, $product->id) and Product::duplicateQuantityDiscount($id_product_old, $product->id) and Pack::duplicate($id_product_old, $product->id) and Product::duplicateCustomizationFields($id_product_old, $product->id) and Product::duplicateTags($id_product_old, $product->id)) {
                        if (!Tools::getValue('noimage') and !Image::duplicateProductImages($id_product_old, $product->id, $combinationImages)) {
                            $this->_errors[] = Tools::displayError('an error occurred while copying images');
                        } else {
                            Hook::addProduct($product);
                            Search::indexation(false);
                            Tools::redirectAdmin($currentIndex . '&id_category=' . intval(Tools::getValue('id_category')) . '&conf=19&token=' . ($token ? $token : $this->token));
                        }
                    } else {
                        $this->_errors[] = Tools::displayError('an error occurred while creating object');
                    }
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
            }
        } elseif ($id_image = intval(Tools::getValue('id_image')) and Validate::isUnsignedId($id_image) and Validate::isLoadedObject($image = new Image($id_image))) {
            if ($this->tabAccess['edit'] === '1') {
                /* Delete product image */
                if (isset($_GET['deleteImage'])) {
                    $image->delete();
                    deleteImage($image->id_product, $image->id);
                    if (!Image::getCover($image->id_product)) {
                        $first_img = Db::getInstance()->getRow('
						SELECT `id_image` FROM `' . _DB_PREFIX_ . 'image`
						WHERE `id_product` = ' . intval($image->id_product));
                        Db::getInstance()->Execute('
						UPDATE `' . _DB_PREFIX_ . 'image`
						SET `cover` = 1
						WHERE `id_image` = ' . intval($first_img['id_image']));
                    }
                    @unlink(dirname(__FILE__) . '/../../img/tmp/product_' . $image->id_product . '.jpg');
                    @unlink(dirname(__FILE__) . '/../../img/tmp/product_mini_' . $image->id_product . '.jpg');
                    Tools::redirectAdmin($currentIndex . '&id_product=' . $image->id_product . '&id_category=' . intval(Tools::getValue('id_category')) . '&add' . $this->table . '&tabs=1' . '&token=' . ($token ? $token : $this->token));
                } elseif (isset($_GET['editImage'])) {
                    if ($image->cover) {
                        $_POST['cover'] = 1;
                    }
                    $languages = Language::getLanguages();
                    foreach ($languages as $language) {
                        if (isset($image->legend[$language['id_lang']])) {
                            $_POST['legend_' . $language['id_lang']] = $image->legend[$language['id_lang']];
                        }
                    }
                    $_POST['id_image'] = $image->id;
                    $this->displayForm($token ? $token : $this->token);
                } elseif (isset($_GET['coverImage'])) {
                    Image::deleteCover($image->id_product);
                    $image->cover = 1;
                    if (!$image->update()) {
                        $this->_errors[] = Tools::displayError('Impossible to change the product cover');
                    } else {
                        $productId = intval(Tools::getValue('id_product'));
                        @unlink(dirname(__FILE__) . '/../../img/tmp/product_' . $productId . '.jpg');
                        @unlink(dirname(__FILE__) . '/../../img/tmp/product_mini_' . $productId . '.jpg');
                        Tools::redirectAdmin($currentIndex . '&id_product=' . $image->id_product . '&id_category=' . intval(Tools::getValue('id_category')) . '&addproduct&tabs=1' . '&token=' . ($token ? $token : $this->token));
                    }
                } elseif (isset($_GET['imgPosition']) and isset($_GET['imgDirection'])) {
                    $image->positionImage(intval(Tools::getValue('imgPosition')), intval(Tools::getValue('imgDirection')));
                    Tools::redirectAdmin($currentIndex . '&id_product=' . $image->id_product . '&id_category=' . intval(Tools::getValue('id_category')) . '&add' . $this->table . '&tabs=1&token=' . ($token ? $token : $this->token));
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
            }
        } elseif (Tools::isSubmit('submitProductAttribute')) {
            if (Validate::isLoadedObject($product = new Product(intval(Tools::getValue('id_product'))))) {
//.........这里部分代码省略.........
开发者ID:raulgimenez,项目名称:dreamongraphics_shop,代码行数:101,代码来源:AdminProducts.php

示例15: Product

include 'layout/_header.php';
if (!empty($_GET['productId'])) {
    include_once 'tools.php';
    $prodObj = new Product();
    $product = $prodObj->findById($connect, $_GET['productId']);
    if (!empty($product)) {
        ?>
        <h4> Are you sure want to delete this product?</h4>
        <form action='' method=post>
            <input type="hidden" name="id" id="id" value="<?php 
        echo empty($product) ? '' : $product->id;
        ?>
"/>
            <input class="button button-yes" type=submit name='btnYes' value='Yes'>
            <input class="button button-no" type=submit name='btnNo' value='No'>

        </form>
        <?php 
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (isset($_POST['btnYes'])) {
            $prodObj->delete($_POST['id'], $connect);
        }
        header("Location: /");
        return;
    }
    $connect->close();
} else {
    echo '<h4>Error: No product to delete</h4>';
}
include 'layout/_footer.php';
开发者ID:andriychernyukh,项目名称:Market,代码行数:31,代码来源:delete.php


注:本文中的Product::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。