本文整理汇总了PHP中SpecificPrice::deleteByProductId方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecificPrice::deleteByProductId方法的具体用法?PHP SpecificPrice::deleteByProductId怎么用?PHP SpecificPrice::deleteByProductId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecificPrice
的用法示例。
在下文中一共展示了SpecificPrice::deleteByProductId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Product
$id_product = (int) $line[0];
$product = new Product($id_product, true, 1);
$newPrice = (double) $line[1];
$mrp = $product->getPriceWithoutReduct();
$product = new Order($id_order);
SpecificPrice::deleteByProductId($id_product);
$specificPriceIDs = SpecificPrice::getIdsByProductId($id_product);
if (count($specificPriceIDs) > 0) {
$specificPrice = new SpecificPrice((int) $specificPriceIDs[0]['id_specific_price']);
//delete discount if the prices are equal update otherwise
if (round($mrp) > round($newPrice)) {
$specificPrice->reduction_type = "amount";
$specificPrice->reduction = $mrp - $newPrice;
$specificPrice->update();
} else {
SpecificPrice::deleteByProductId($id_product);
}
} else {
if (round($mrp) > round($newPrice)) {
$specificPrice = new SpecificPrice();
$specificPrice->id_product = $id_product;
$specificPrice->reduction_type = "amount";
$specificPrice->reduction = $mrp - $newPrice;
$specificPrice->from_quantity = 1;
$specificPrice->from = date('Y-m-d H:i:s');
$specificPrice->update();
}
}
SolrSearch::updateProduct($id_product);
$count++;
}
示例2: delete
public function delete()
{
if (!GroupReduction::deleteProductReduction($this->id)) {
return false;
}
Hook::deleteProduct($this);
if (!parent::delete() or !$this->deleteCategories(true) or !$this->deleteImages() or !$this->deleteProductAttributes() or !$this->deleteProductFeatures() or !$this->deleteTags() or !$this->deleteCartProducts() or !$this->deleteAttributesImpacts() or !$this->deleteAttachments() or !$this->deleteCustomization() or !SpecificPrice::deleteByProductId((int) $this->id) or !$this->deletePack() or !$this->deleteProductSale() or !$this->deleteSceneProducts() or !$this->deleteSearchIndexes() or !$this->deleteAccessories() or !$this->deleteFromAccessories()) {
return false;
}
if ($id = ProductDownload::getIdFromIdProduct($this->id)) {
if ($productDownload = new ProductDownload($id) and !$productDownload->delete(true)) {
return false;
}
}
return true;
}
示例3: delete
public function delete()
{
/*
* @since 1.5.0
* It is NOT possible to delete a product if there are currently:
* - physical stock for this product
* - supply order(s) for this product
*/
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $this->advanced_stock_management) {
$stock_manager = StockManagerFactory::getManager();
$physical_quantity = $stock_manager->getProductPhysicalQuantities($this->id, 0);
$real_quantity = $stock_manager->getProductRealQuantities($this->id, 0);
if ($physical_quantity > 0) {
return false;
}
if ($real_quantity > $physical_quantity) {
return false;
}
}
// Removes the product from StockAvailable, for the current shop
StockAvailable::removeProductFromStockAvailable($this->id);
$result = parent::delete();
$result &= $this->deleteProductAttributes() && $this->deleteImages() && $this->deleteSceneProducts();
// If there are still entries in product_shop, don't remove completly the product
if ($this->hasMultishopEntries()) {
return true;
}
Hook::exec('actionProductDelete', array('product' => $this));
if (!$result || !GroupReduction::deleteProductReduction($this->id) || !$this->deleteCategories(true) || !$this->deleteProductFeatures() || !$this->deleteTags() || !$this->deleteCartProducts() || !$this->deleteAttributesImpacts() || !$this->deleteAttachments() || !$this->deleteCustomization() || !SpecificPrice::deleteByProductId((int) $this->id) || !$this->deletePack() || !$this->deleteProductSale() || !$this->deleteSearchIndexes() || !$this->deleteAccessories() || !$this->deleteFromAccessories() || !$this->deleteFromSupplier() || !$this->deleteDownload() || !$this->deleteFromCartRules()) {
return false;
}
return true;
}
示例4: handleConfirm
//.........这里部分代码省略.........
$product->as_shown = $as_shown;
$product->id_sizechart = $id_sizechart;
$product->is_exclusive = $is_exclusive;
$product->handbag_occasion = $handbag_occasion;
$product->handbag_style = $handbag_style;
$product->handbag_material = $handbag_material;
$product->indexed = 0;
$products_to_import[] = $product;
} else {
$smarty->assign('error', $error);
return;
$file_error = true;
}
}
if (!$file_error) {
$added_product_ids = array();
foreach ($products_to_import as $product) {
$fieldError = $product->validateFields(UNFRIENDLY_ERROR, true);
$langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
if ($fieldError === true and $langFieldError === true) {
// check quantity
if ($product->quantity == NULL) {
$product->quantity = 0;
}
// If no id_product or update failed
if ($update && $product->id) {
$res = $product->update();
} else {
$res = $product->add();
}
$added_product_ids[] = $product->id;
}
if (isset($product->discount) && $product->discount > 0) {
SpecificPrice::deleteByProductId((int) $product->id);
$specificPrice = new SpecificPrice();
$specificPrice->id_product = (int) $product->id;
$specificPrice->id_shop = (int) Shop::getCurrentShop();
$specificPrice->id_currency = 0;
$specificPrice->id_country = 0;
$specificPrice->id_group = 0;
$specificPrice->from_quantity = 1;
$specificPrice->reduction = $product->discount / 100;
$specificPrice->reduction_type = 'percentage';
$specificPrice->from = '2012-01-01 00:00:00';
$specificPrice->to = '2016-01-01 00:00:00';
$specificPrice->price = $product->price;
$specificPrice->add();
}
if (isset($product->tags) and !empty($product->tags)) {
// Delete tags for this id product, for no duplicating error
Tag::deleteTagsForProduct($product->id);
$tag = new Tag();
$tag->addTags($defaultLanguageId, $product->id, $tags);
}
if (isset($product->images) and is_array($product->images) and sizeof($product->images) and !$update || $overwrite_imgs == "on") {
$product->deleteImages();
$first_image = true;
foreach ($product->images as $image_name) {
$image_name = trim($image_name);
$image_path = IMAGE_UPLOAD_PATH . $image_name;
if (!empty($image_name)) {
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = $first_image;
$image->legend[$defaultLanguageId] = $product->name[$defaultLanguageId];
示例5: delete
public function delete()
{
/*
* @since 1.5.0
* It is NOT possible to delete a product if there are currently:
* - physical stock for this product
* - supply order(s) for this product
*/
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $this->advanced_stock_management) {
$stock_manager = StockManagerFactory::getManager();
$physical_quantity = $stock_manager->getProductPhysicalQuantities($this->id, 0);
$real_quantity = $stock_manager->getProductRealQuantities($this->id, 0);
if ($physical_quantity > 0) {
return false;
}
if ($real_quantity > $physical_quantity) {
return false;
}
$warehouse_product_locations = \PrestaShop\PrestaShop\Adapter\ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\EntityManager')->getRepository('WarehouseProductLocation')->findByIdProduct($this->id);
foreach ($warehouse_product_locations as $warehouse_product_location) {
$warehouse_product_location->delete();
}
$stocks = \PrestaShop\PrestaShop\Adapter\ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\EntityManager')->getRepository('Stock')->findByIdProduct($this->id);
foreach ($stocks as $stock) {
$stock->delete();
}
}
$result = parent::delete();
// Removes the product from StockAvailable, for the current shop
StockAvailable::removeProductFromStockAvailable($this->id);
$result &= $this->deleteProductAttributes() && $this->deleteImages();
// If there are still entries in product_shop, don't remove completely the product
if ($this->hasMultishopEntries()) {
return true;
}
Hook::exec('actionProductDelete', array('id_product' => (int) $this->id, 'product' => $this));
if (!$result || !GroupReduction::deleteProductReduction($this->id) || !$this->deleteCategories(true) || !$this->deleteProductFeatures() || !$this->deleteTags() || !$this->deleteCartProducts() || !$this->deleteAttributesImpacts() || !$this->deleteAttachments(false) || !$this->deleteCustomization() || !SpecificPrice::deleteByProductId((int) $this->id) || !$this->deletePack() || !$this->deleteProductSale() || !$this->deleteSearchIndexes() || !$this->deleteAccessories() || !$this->deleteFromAccessories() || !$this->deleteFromSupplier() || !$this->deleteDownload() || !$this->deleteFromCartRules()) {
return false;
}
return true;
}
示例6: delete
public function delete($force_delete = false)
{
// check if the product is not used in a non validated order
if (!$force_delete && !$this->isDeletable()) {
return false;
}
if (!$force_delete && !GroupReduction::deleteProductReduction($this->id)) {
return false;
}
Hook::deleteProduct($this);
if (!parent::delete() || !$this->deleteCategories(true) || !$this->deleteProductAttributes() || !$this->deleteProductFeatures() || !$this->deleteTags() || !$this->deleteCartProducts() || !$this->deleteAttachments() || !$this->deleteCustomization() || !SpecificPrice::deleteByProductId((int) $this->id) || !$this->deletePack() || !$this->deleteProductSale() || !$this->deleteSceneProducts() || !$this->deleteSearchIndexes() || !$this->deleteAccessories() || !$this->deleteFromAccessories()) {
return false;
}
if (!_PS_MODE_DEMO_ && !$this->deleteImages()) {
return false;
}
if ($id = ProductDownload::getIdFromIdProduct($this->id)) {
if ($productDownload = new ProductDownload($id)) {
if (!$productDownload->delete(true)) {
return false;
}
}
}
return true;
}
示例7: productImport
//.........这里部分代码省略.........
}
}
if (!$valid_link) {
$this->_warnings[] = Tools::displayError('Rewrite link for') . ' ' . $link_rewrite . (isset($info['id']) ? ' (ID ' . $info['id'] . ') ' : '') . ' ' . Tools::displayError('was re-written as') . ' ' . $link_rewrite;
}
$product->link_rewrite = self::createMultiLangField($link_rewrite);
$res = false;
$fieldError = $product->validateFields(UNFRIENDLY_ERROR, true);
$langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
if ($fieldError === true and $langFieldError === true) {
// check quantity
if ($product->quantity == NULL) {
$product->quantity = 0;
}
// If id product AND id product already in base, trying to update
if ($product->id and Product::existsInDatabase((int) $product->id)) {
$datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . (int) $product->id);
$product->date_add = pSQL($datas['date_add']);
$res = $product->update();
}
// If no id_product or update failed
if (!$res) {
$res = $product->add();
}
$productIds[] = $product->id;
}
// If both failed, mysql error
if (!$res) {
$this->_errors[] = $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
} else {
// SpecificPrice (only the basic reduction feature is supported by the import)
if (isset($info['reduction_price']) and $info['reduction_price'] > 0 or isset($info['reduction_percent']) and $info['reduction_percent'] > 0) {
SpecificPrice::deleteByProductId((int) $product->id);
$specificPrice = new SpecificPrice();
$specificPrice->id_product = (int) $product->id;
$specificPrice->id_shop = (int) Shop::getCurrentShop();
$specificPrice->id_currency = 0;
$specificPrice->id_country = 0;
$specificPrice->id_group = 0;
$specificPrice->price = 0.0;
$specificPrice->from_quantity = 1;
$specificPrice->reduction = (isset($info['reduction_price']) and $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
$specificPrice->reduction_type = (isset($info['reduction_price']) and $info['reduction_price']) ? 'amount' : 'percentage';
$specificPrice->from = (isset($info['reduction_from']) and Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
$specificPrice->to = (isset($info['reduction_to']) and Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
if (!$specificPrice->add()) {
$this->_addProductWarning($info['name'], $product->id, $this->l('Discount is invalid'));
}
}
if (isset($product->tags) and !empty($product->tags)) {
// Delete tags for this id product, for no duplicating error
Tag::deleteTagsForProduct($product->id);
$tag = new Tag();
if (!is_array($product->tags)) {
$product->tags = self::createMultiLangField($product->tags);
foreach ($product->tags as $key => $tags) {
$isTagAdded = $tag->addTags($key, $product->id, $tags);
if (!$isTagAdded) {
$this->_addProductWarning($info['name'], $product->id, $this->l('Tags list') . ' ' . $this->l('is invalid'));
break;
}
}
} else {
foreach ($product->tags as $key => $tags) {
$str = '';