public function importIdeasOrTips($aDataToImported, &$aDataImported) { foreach ($aDataToImported as $aData) { if (empty($aData['error'])) { // get product information $aProduct = NowProduct::getProductLight($aData['id_product']); // 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', 'AdminNowImportTipsAndIdeas'), $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', 'AdminNowImportTipsAndIdeas'), $aProduct['reference']); } $aDataImported[] = array('id_product' => $aProduct['id_product'], 'product_reference' => $aProduct['reference'], 'product_name' => $aProduct['name'], 'ideas_tips' => $this->getNewIdeasOrTips($aData['ideas_tips']), 'error' => $aData['error']); } else { $this->errors[] = $aData['error']; } } }
/** * @param $aDataToImported * @param $aDataImported */ public function importProductTypes($aDataToImported, &$aDataImported) { foreach ($aDataToImported as $aData) { if (empty($aData['error'])) { // On récupère le type de produit $oNowProductTypeProduct = NowProductTypeProduct::getObjectByProductId($aData['id_product']); if (Validate::isLoadedObject($oNowProductTypeProduct)) { // Il est valide, on le modifie $oNowProductTypeProduct->id_now_product_type = (int) $aData['id_now_product_type']; $oNowProductTypeProduct->active = (bool) $aData['active']; $oNowProductTypeProduct->update(); } else { // 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(); } // get product information $aProduct = NowProduct::getProductLight($aData['id_product']); $aDataImported[] = array('id_product' => $aProduct['id_product'], 'product_reference' => $aProduct['reference'], 'product_name' => $aProduct['name'], 'id_now_product_type' => $oNowProductTypeProduct->id_now_product_type, 'active' => $aData['active'], 'error' => $aData['error']); } else { $this->errors[] = $aData['error']; } } }
/** * @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']; } } }
/** * 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']; } } }