本文整理汇总了PHP中Pack::deleteItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Pack::deleteItems方法的具体用法?PHP Pack::deleteItems怎么用?PHP Pack::deleteItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pack
的用法示例。
在下文中一共展示了Pack::deleteItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePackItems
public function updatePackItems($product)
{
Pack::deleteItems($product->id);
if (Tools::getValue('ppack') and $items = Tools::getValue('inputPackItems') and sizeof($ids = array_unique(explode('-', $items)))) {
if (!Pack::addItems($product->id, $ids)) {
return false;
}
}
return true;
}
示例2: updatePackItems
public function updatePackItems($product)
{
Pack::deleteItems($product->id);
// lines format: QTY x ID-QTY x ID
if (Tools::getValue('ppack') and $items = Tools::getValue('inputPackItems') and sizeof($lines = array_unique(explode('-', $items)))) {
foreach ($lines as $line) {
// line format QTY x ID
list($qty, $item_id) = explode('x', $line);
if ($qty > 0 && isset($item_id)) {
if (!Pack::addItem((int) $product->id, (int) $item_id, (int) $qty)) {
return false;
}
}
}
}
return true;
}
示例3: setWsProductBundle
public function setWsProductBundle($items)
{
if ($this->is_virtual) {
return false;
}
Pack::deleteItems($this->id);
foreach ($items as $item) {
if ((int) $item['id'] > 0) {
Pack::addItem($this->id, (int) $item['id'], (int) $item['quantity']);
}
}
return true;
}
示例4: importFile
/**
* @param $aDataToImported
* @param $aDataImported
*/
public function importFile($aDataToImported, &$aDataImported)
{
foreach ($aDataToImported as $aData) {
if (empty($aData['error'])) {
// Get product information
$aProduct = NowProduct::getProductLight($aData['id_product']);
// Gestion des accessoires
// Delete old accessories
if (!NowProduct::deleteAccessories($aData['id_product'])) {
$aData['error'] = sprintf($this->module->l('Impossible to deleting old accesories to this product: %s', 'AdminNowAllImport'), $aProduct['reference']);
}
// Insert new accesssories
if (!NowProduct::changeAccessories($aData['id_product'], explode('::', $aData['accessories']))) {
$aData['error'] = sprintf($this->module->l('Impossible to adding the new accesories to this product: %s', 'AdminNowAllImport'), $aProduct['reference']);
}
// Gestion des types de produits
// On récupère le type de produit
$oNowProductTypeProduct = NowProductTypeProduct::getObjectByProductId($aData['id_product']);
if (Validate::isLoadedObject($oNowProductTypeProduct)) {
// Il est valide, on le supprime
$oNowProductTypeProduct->delete();
}
if (isset($aData['id_now_product_type']) && (bool) $aData['id_now_product_type']) {
// On l'ajoute de nouveau
$oNowProductTypeProduct = new NowProductTypeProduct();
$oNowProductTypeProduct->id_product = (int) $aData['id_product'];
$oNowProductTypeProduct->id_now_product_type = (int) $aData['id_now_product_type'];
$oNowProductTypeProduct->active = (bool) $aData['active'];
$oNowProductTypeProduct->add();
}
// Gestion des conseils ou idées
// Delete old ideas or tips
if (!NowIdeasOrTips::deleteIdeasOrTips($aData['id_product'])) {
$aData['error'] = sprintf($this->module->l('Impossible to deleting old ideas or tips to this product: %s', 'AdminNowAllImport'), $aProduct['reference']);
}
// Insert new ideas or tips
if (!NowIdeasOrTips::changeIdeasOrTips($aData['id_product'], explode('::', $aData['ideas_tips']))) {
$aData['error'] = sprintf($this->module->l('Impossible to adding the new ideas or tips to this product: %s', 'AdminNowAllImport'), $aProduct['reference']);
}
// Gestion des packs de produits
// Delete old products pack
if (!Pack::deleteItems($aData['id_product'])) {
$aData['error'] = sprintf($this->module->l('Impossible to deleting old product to this product pack: %s', 'AdminNowAllImport'), $aProduct['reference']);
}
// Insert new products pack
if (!NowProduct::changeProductsPacks($aData['id_product'], explode('::', $aData['products_pack']))) {
$aData['error'] = sprintf($this->module->l('Impossible to adding the new product to this product pack: %s', 'AdminNowAllImport'), $aProduct['reference']);
}
$aDataImported[] = array('id_product' => $aProduct['id_product'], 'product_reference' => $aProduct['reference'], 'product_name' => $aProduct['name'], 'active' => $aData['active'], 'accessories' => isset($aData['accessories']) && $aData['accessories'] ? $this->getNewAccessories($aData['accessories']) : '', 'id_now_product_type' => Validate::isLoadedObject($oNowProductTypeProduct) ? $oNowProductTypeProduct->id_now_product_type : '', 'ideas_tips' => isset($aData['ideas_tips']) && $aData['ideas_tips'] ? $this->getNewIdeasOrTips($aData['ideas_tips']) : '', 'products_pack' => isset($aData['products_pack']) && $aData['products_pack'] ? $this->getNewProductsPacks($aData['products_pack']) : '', 'error' => $aData['error']);
} else {
$this->errors[] = $aData['error'];
}
}
}
示例5: importProductsPacks
/**
* Permet d'importer les nouveaux packs de produits
* @param $aDataToImported
* @param $aDataImported
*/
public function importProductsPacks($aDataToImported, &$aDataImported)
{
foreach ($aDataToImported as $aData) {
if (empty($aData['error'])) {
// get product information
$aProduct = NowProduct::getProductLight($aData['id_product']);
// Delete old products pack
if (!Pack::deleteItems($aData['id_product'])) {
$aData['error'] = sprintf($this->module->l('Impossible to deleting old product to this product pack: %s', 'AdminNowImportPacks'), $aProduct['reference']);
}
// Insert new products pack
if (!NowProduct::changeProductsPacks($aData['id_product'], explode('::', $aData['products_pack']))) {
$aData['error'] = sprintf($this->module->l('Impossible to adding the new product to this product pack: %s', 'AdminNowImportPacks'), $aProduct['reference']);
}
$aDataImported[] = array('id_product' => $aProduct['id_product'], 'product_reference' => $aProduct['reference'], 'product_name' => $aProduct['name'], 'products_pack' => $this->getNewProductsPacks($aData['products_pack']), 'error' => $aData['error']);
} else {
$this->errors[] = $aData['error'];
}
}
}
示例6: updatePackItems
/**
* delete all items in pack, then check if type_product value is 2.
* if yes, add the pack items from input "inputPackItems"
*
* @param Product $product
* @return boolean
*/
public function updatePackItems($product)
{
Pack::deleteItems($product->id);
// lines format: QTY x ID-QTY x ID
if (Tools::getValue('type_product') == Product::PTYPE_PACK) {
$items = Tools::getValue('inputPackItems');
$lines = array_unique(explode('-', $items));
// lines is an array of string with format : QTYxID
if (count($lines)) {
foreach ($lines as $line) {
if (!empty($line)) {
list($qty, $item_id) = explode('x', $line);
if ($qty > 0 && isset($item_id)) {
if (!Pack::addItem((int) $product->id, (int) $item_id, (int) $qty)) {
$this->errors[] = Tools::displayError('An error occurred while adding products to the pack.');
}
}
}
}
}
}
}