本文整理汇总了PHP中Pack::duplicate方法的典型用法代码示例。如果您正苦于以下问题:PHP Pack::duplicate方法的具体用法?PHP Pack::duplicate怎么用?PHP Pack::duplicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pack
的用法示例。
在下文中一共展示了Pack::duplicate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'))))) {
//.........这里部分代码省略.........
示例2: foreach
foreach ($shops as $shop) {
if ($product->isAssociatedToShop($shop['id_shop'])) {
$product_price = new Product($id_product_old, false, null, $shop['id_shop']);
$product->price = $product_price->price;
}
}
}
if (Validate::isLoadedObject($product)) {
$id_product_old = $product->id;
for ($i = 1; $i <= $quantity; $i++) {
echo $i;
unset($product->id);
unset($product->id_product);
$product->indexed = 0;
$product->active = 0;
if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) {
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($product->id);
}
if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) {
echo 'An error occurred while copying images.';
} else {
Hook::exec('actionProductAdd', array('product' => $product));
if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $product->id);
}
echo ' Duplication, ProductAddHook and re-index done. ';
}
} else {
echo 'An error occurred while duplicating some object properties.';
}
示例3: postProcess
//.........这里部分代码省略.........
}
}
$attachment->file = $uniqid;
$attachment->mime = $_FILES['attachment_file']['type'];
$attachment->file_name = pSQL($_FILES['attachment_file']['name']);
if (empty($attachment->mime) or Tools::strlen($attachment->mime) > 128) {
$this->_errors[] = Tools::displayError('Invalid file extension');
}
if (!Validate::isGenericName($attachment->file_name)) {
$this->_errors[] = Tools::displayError('Invalid file name');
}
if (Tools::strlen($attachment->file_name) > 128) {
$this->_errors[] = Tools::displayError('File name too long');
}
if (!sizeof($this->_errors)) {
$attachment->add();
Tools::redirectAdmin($currentIndex . '&id_product=' . (int) Tools::getValue($this->identifier) . '&id_category=' . (int) Tools::getValue('id_category') . '&addproduct&conf=4&tabs=6&token=' . ($token ? $token : $this->token));
} else {
$this->_errors[] = Tools::displayError('Invalid file');
}
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
} elseif (Tools::isSubmit('submitAttachments')) {
if ($this->tabAccess['edit'] === '1') {
if ($id = (int) Tools::getValue($this->identifier)) {
if (Attachment::attachToProduct($id, $_POST['attachments'])) {
Tools::redirectAdmin($currentIndex . '&id_product=' . (int) $id . (isset($_POST['id_category']) ? '&id_category=' . (int) $_POST['id_category'] : '') . '&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((int) Tools::getValue('id_product')))) {
$id_product_old = $product->id;
unset($product->id);
unset($product->id_product);
$product->indexed = 0;
$product->active = 0;
if ($product->add() and Category::duplicateProductCategories($id_product_old, $product->id) and ($combinationImages = Product::duplicateAttributes($id_product_old, $product->id)) !== false and GroupReduction::duplicateReduction($id_product_old, $product->id) and Product::duplicateAccessories($id_product_old, $product->id) and Product::duplicateFeatures($id_product_old, $product->id) and Product::duplicateSpecificPrices($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) and Product::duplicateDownload($id_product_old, $product->id)) {
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($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, $product->id);
Tools::redirectAdmin($currentIndex . '&id_category=' . (!empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1') . '&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 here.');
}
} elseif (isset($_GET['status']) and Tools::getValue($this->identifier)) {
if ($this->tabAccess['edit'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->toggleStatus()) {
Tools::redirectAdmin($currentIndex . '&conf=5' . (($id_category = !empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1' and Tools::getValue('id_product')) ? '&id_category=' . $id_category : '') . '&token=' . $token);
} else {
$this->_errors[] = Tools::displayError('An error occurred while updating status.');