本文整理汇总了PHP中Tag::deleteTagsForProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::deleteTagsForProduct方法的具体用法?PHP Tag::deleteTagsForProduct怎么用?PHP Tag::deleteTagsForProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::deleteTagsForProduct方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: productImport
//.........这里部分代码省略.........
if (!$res) {
if (isset($product->date_add) && $product->date_add != '') {
$res = $product->add(false);
} else {
$res = $product->add();
}
}
}
// 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 = 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 = '';
foreach ($tags as $one_tag) {
$str .= $one_tag . ',';
}
$str = rtrim($str, ',');
$isTagAdded = $tag->addTags($key, $product->id, $str);
if (!$isTagAdded) {
$this->_addProductWarning($info['name'], $product->id, 'Invalid tag(s) (' . $str . ')');
break;
}
}
}
}
//delete existing images if "delete_existing_images" is set to 1
if (isset($product->delete_existing_images)) {
if ((bool) $product->delete_existing_images) {
$product->deleteImages();
} elseif (isset($product->image) and is_array($product->image) and sizeof($product->image)) {
$product->deleteImages();
}
示例2: deleteTags
/**
* Delete products tags entries
*
* @return array Deletion result
*/
public function deleteTags()
{
return Tag::deleteTagsForProduct((int) $this->id);
}
示例3: productImportOne
//.........这里部分代码省略.........
$specific_price->id_country = 0;
$specific_price->id_group = 0;
$specific_price->price = -1;
$specific_price->id_customer = 0;
$specific_price->from_quantity = 1;
$specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
$specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
$specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
$specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
if (!$validateOnly && !$specific_price->save()) {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
}
}
}
if (!$validateOnly && isset($product->tags) && !empty($product->tags)) {
if (isset($product->id) && $product->id) {
$tags = Tag::getProductTags($product->id);
if (is_array($tags) && count($tags)) {
if (!empty($product->tags)) {
$product->tags = explode($this->multiple_value_separator, $product->tags);
}
if (is_array($product->tags) && count($product->tags)) {
foreach ($product->tags as $key => $tag) {
if (!empty($tag)) {
$product->tags[$key] = trim($tag);
}
}
$tags[$id_lang] = $product->tags;
$product->tags = $tags;
}
}
}
// Delete tags for this id product, for no duplicating error
Tag::deleteTagsForProduct($product->id);
if (!is_array($product->tags) && !empty($product->tags)) {
$product->tags = AdminImportController::createMultiLangField($product->tags);
foreach ($product->tags as $key => $tags) {
$is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
if (!$is_tag_added) {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
break;
}
}
} else {
foreach ($product->tags as $key => $tags) {
$str = '';
foreach ($tags as $one_tag) {
$str .= $one_tag . $this->multiple_value_separator;
}
$str = rtrim($str, $this->multiple_value_separator);
$is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
if (!$is_tag_added) {
$this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')');
break;
}
}
}
}
//delete existing images if "delete_existing_images" is set to 1
if (!$validateOnly && isset($product->delete_existing_images)) {
if ((bool) $product->delete_existing_images) {
$product->deleteImages();
}
}
if (!$validateOnly && isset($product->image) && is_array($product->image) && count($product->image)) {
$product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id);
示例4: handleConfirm
//.........这里部分代码省略.........
$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];
if (($fieldError = $image->validateFields(false, true)) === true and ($langFieldError = $image->validateFieldsLang(false, true)) === true and $image->add()) {
if (!self::copyImg($product->id, $image->id, $image_path)) {
$_warnings[] = Tools::displayError('Error copying image: ') . $image_path;
} else {
//delete the original image
@unlink($image_path);
}
} else {
$_warnings[] = $image->legend[$defaultLanguageId] . (isset($image->id_product) ? ' (' . $image->id_product . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
$first_image = false;
}
}
if (isset($product->id_category)) {
$product->updateCategories(array_map('intval', $product->id_category));
示例5: updateTags
public function updateTags($languages, $product)
{
${${"GLOBALS"}["eexlddxulmu"]} = true;
$iqvagwtobzz = "tag_success";
if (!Tag::deleteTagsForProduct((int) $product->id)) {
$this->errors[] = Tools::displayError("An error occurred while attempting to delete previous tags.");
}
foreach (${${"GLOBALS"}["emgichjdg"]} as ${${"GLOBALS"}["exhdxhsxzdo"]}) {
if (${${"GLOBALS"}["kzwkbwmzgtl"]} = Tools::getValue("tags_" . ${${"GLOBALS"}["exhdxhsxzdo"]}["id_lang"])) {
${${"GLOBALS"}["eexlddxulmu"]} &= Tag::addTags(${${"GLOBALS"}["exhdxhsxzdo"]}["id_lang"], (int) $product->id, ${${"GLOBALS"}["kzwkbwmzgtl"]});
}
}
$jgkmbwkqkq = "tag_success";
if (!${$iqvagwtobzz}) {
$this->errors[] = Tools::displayError("An error occurred while adding tags.");
}
return ${$jgkmbwkqkq};
}
示例6: productImport
//.........这里部分代码省略.........
$product_supplier = new ProductSupplier((int) $id_product_supplier);
} else {
$product_supplier = new ProductSupplier();
}
$product_supplier->id_product = $product->id;
$product_supplier->id_product_attribute = 0;
$product_supplier->id_supplier = $product->id_supplier;
$product_supplier->product_supplier_price_te = $product->wholesale_price;
$product_supplier->product_supplier_reference = $product->supplier_reference;
$product_supplier->save();
}
// SpecificPrice (only the basic reduction feature is supported by the import)
if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
$specific_price = new SpecificPrice();
$specific_price->id_product = (int) $product->id;
// @todo multishop specific price import
$specific_price->id_shop = $this->context->shop->id;
$specific_price->id_currency = 0;
$specific_price->id_country = 0;
$specific_price->id_group = 0;
$specific_price->price = -1;
$specific_price->id_customer = 0;
$specific_price->from_quantity = 1;
$specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
$specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
$specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
$specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
if (!$specific_price->add()) {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
}
}
if (isset($product->tags) && !empty($product->tags)) {
// Delete tags for this id product, for no duplicating error
Tag::deleteTagsForProduct($product->id);
if (!is_array($product->tags)) {
$product->tags = AdminImportController::createMultiLangField($product->tags);
foreach ($product->tags as $key => $tags) {
$is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
if (!$is_tag_added) {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
break;
}
}
} else {
foreach ($product->tags as $key => $tags) {
$str = '';
foreach ($tags as $one_tag) {
$str .= $one_tag . $this->multiple_value_separator;
}
$str = rtrim($str, $this->multiple_value_separator);
$is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
if (!$is_tag_added) {
$this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')');
break;
}
}
}
}
//delete existing images if "delete_existing_images" is set to 1
if (isset($product->delete_existing_images)) {
if ((bool) $product->delete_existing_images) {
$product->deleteImages();
} else {
if (isset($product->image) && is_array($product->image) && count($product->image)) {
$product->deleteImages();
}
示例7: productImport
//.........这里部分代码省略.........
$valid_link = Validate::isLinkRewrite($link_rewrite);
$bak = $product->link_rewrite;
if (isset($product->link_rewrite[$defaultLanguageId]) and empty($product->link_rewrite[$defaultLanguageId]) or !$valid_link) {
$link_rewrite = Tools::link_rewrite($product->name[$defaultLanguageId]);
if ($link_rewrite == '') {
$link_rewrite = 'friendly-url-autogeneration-failed';
}
}
if (!$valid_link) {
$this->_warnings[] = Tools::displayError('Rewrited link for') . ' ' . $bak . (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(intval($product->id))) {
$datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . intval($product->id));
$product->date_add = pSQL($datas['date_add']);
$res = $product->update();
}
// If no id_product or update failed
if (!$res) {
$res = $product->add();
}
}
// 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 {
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 = '';
foreach ($tags as $one_tag) {
$str .= $one_tag . ',';
}
$str = rtrim($str, ',');
$isTagAdded = $tag->addTags($key, $product->id, $str);
if (!$isTagAdded) {
$this->_addProductWarning($info['name'], $product->id, 'Invalid tag(s) (' . $str . ')');
break;
}
}
}
}
if (isset($product->image) and is_array($product->image) and sizeof($product->image)) {
$productHasImages = (bool) Image::getImages(intval($cookie->id_lang), intval($product->id));
foreach ($product->image as $key => $url) {
if (!empty($url)) {
$image = new Image();
$image->id_product = intval($product->id);
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = (!$key and !$productHasImages) ? true : false;
$image->legend = self::createMultiLangField($product->name[$defaultLanguageId]);
if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $image->add()) {
if (!self::copyImg($product->id, $image->id, $url)) {
$this->_warnings[] = Tools::displayError('Error copying image: ') . $url;
}
} else {
$this->_warnings[] = $image->legend[$defaultLanguageId] . (isset($image->id_product) ? ' (' . $image->id_product . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
}
if (isset($product->id_category)) {
$product->updateCategories(array_map('intval', $product->id_category));
}
$features = get_object_vars($product);
foreach ($features as $feature => $value) {
if (!strncmp($feature, '#F_', 3) and Tools::strlen($product->{$feature})) {
$feature_name = str_replace('#F_', '', $feature);
$id_feature = Feature::addFeatureImport($feature_name);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $product->{$feature});
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
}
}
}
}
$this->closeCsvFile($handle);
}
示例8: productImport
//.........这里部分代码省略.........
$specific_price->id_currency = 0;
$specific_price->id_country = 0;
$specific_price->id_group = 0;
$specific_price->price = -1;
$specific_price->id_customer = 0;
$specific_price->from_quantity = 1;
$specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
$specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
$specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
$specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
if (!$specific_price->save()) {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
}
}
}
if (isset($product->tags) && !empty($product->tags)) {
if (isset($product->id) && $product->id) {
$tags = Tag::getProductTags($product->id);
if (is_array($tags) && count($tags)) {
if (!empty($product->tags)) {
$product->tags = explode($this->multiple_value_separator, $product->tags);
}
if (is_array($product->tags) && count($product->tags)) {
foreach ($product->tags as $key => $tag) {
if (!empty($tag)) {
$product->tags[$key] = trim($tag);
}
}
$tags[$id_lang] = $product->tags;
$product->tags = $tags;
}
}
}
Tag::deleteTagsForProduct($product->id);
if (!is_array($product->tags) && !empty($product->tags)) {
$product->tags = AdminImportController::createMultiLangField($product->tags);
foreach ($product->tags as $key => $tags) {
$is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
if (!$is_tag_added) {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
break;
}
}
} else {
foreach ($product->tags as $key => $tags) {
$str = '';
foreach ($tags as $one_tag) {
$str .= $one_tag . $this->multiple_value_separator;
}
$str = rtrim($str, $this->multiple_value_separator);
$is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
if (!$is_tag_added) {
$this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')');
break;
}
}
}
}
if (isset($product->delete_existing_images)) {
if ((bool) $product->delete_existing_images) {
$product->deleteImages();
}
}
if (isset($product->image) && is_array($product->image) && count($product->image)) {
$product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id);
foreach ($product->image as $key => $url) {