Esempio n. 1
0
                         $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_products_to_categories', 'categories_id=\'' . $relCatId . '\' and products_id=\'' . $prodid . '\'', $updateArray);
                         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                         if ($this->ms['MODULES']['ENABLE_CATEGORIES_TO_CATEGORIES']) {
                             // link to others
                             $foreign_categories = mslib_fe::getForeignCategoriesData($catId, $page_uid);
                             if (is_array($foreign_categories) && count($foreign_categories)) {
                                 $updateArray = array();
                                 $updateArray['categories_id'] = $foreign_categories['categories_id'];
                                 $updateArray['products_id'] = $prodid;
                                 $updateArray['sort_order'] = time();
                                 $updateArray['page_uid'] = $foreign_categories['page_uid'];
                                 $updateArray['related_to'] = $catId;
                                 /*$query=$GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_categories', $updateArray);
                                 		$res=$GLOBALS['TYPO3_DB']->sql_query($query);*/
                                 // create categories tree linking
                                 tx_mslib_catalog::linkCategoriesTreeToProduct($foreign_categories['categories_id'], $catId, $updateArray);
                                 //}
                                 // update the counterpart relation
                                 //$updateArray=array();
                                 //$updateArray['related_to']=$catId;
                                 //$query=$GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_products_to_categories', 'categories_id=\''.$foreign_categories['foreign_categories_id'].'\' and products_id=\''.$prodid.'\'', $updateArray);
                                 //$res=$GLOBALS['TYPO3_DB']->sql_query($query);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 if ($prodid) {
Esempio n. 2
0
 public function duplicateProduct($id_product, $target_categories_id)
 {
     if (!is_numeric($id_product)) {
         return false;
     }
     if (!is_numeric($target_categories_id)) {
         return false;
     }
     $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products', 'products_id=\'' . $id_product . '\'', '', '', '');
     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) == 0) {
         return false;
     } else {
         //insert into tx_multishop_products
         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
         $product_arr_new = array();
         if (is_array($row) && count($row)) {
             foreach ($row as $key_p => $val_p) {
                 if ($key_p != 'products_id') {
                     if ($key_p == 'products_image' or $key_p == 'products_image1' or $key_p == 'products_image2' or $key_p == 'products_image3' or $key_p == 'products_image4') {
                         if (!empty($val_p)) {
                             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_description', 'products_id=\'' . $id_product . '\' and language_id=\'' . $this->sys_language_uid . '\'', '', '', '');
                             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                             $row_desc = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                             $file = mslib_befe::getImagePath($val_p, 'products', 'original');
                             //echo $file;
                             $imgtype = mslib_befe::exif_imagetype($file);
                             if ($imgtype) {
                                 // valid image
                                 $ext = image_type_to_extension($imgtype, false);
                                 if ($ext) {
                                     $i = 0;
                                     $filename = mslib_fe::rewritenamein($row_desc['products_name']) . '.' . $ext;
                                     //echo $filename;
                                     $folder = mslib_befe::getImagePrefixFolder($filename);
                                     $array = explode(".", $filename);
                                     if (!is_dir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder)) {
                                         \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder);
                                     }
                                     $folder .= '/';
                                     $target = $this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename;
                                     //echo $target;
                                     if (file_exists($target)) {
                                         do {
                                             $filename = mslib_fe::rewritenamein($row_desc['products_name']) . ($i > 0 ? '-' . $i : '') . '.' . $ext;
                                             $folder_name = mslib_befe::getImagePrefixFolder($filename);
                                             $array = explode(".", $filename);
                                             $folder = $folder_name;
                                             if (!is_dir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder)) {
                                                 \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder);
                                             }
                                             $folder .= '/';
                                             $target = $this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename;
                                             $i++;
                                             //echo $target . "<br/>";
                                         } while (file_exists($target));
                                     }
                                     if (copy($file, $target)) {
                                         $target_origineel = $target;
                                         $update_product_images = mslib_befe::resizeProductImage($target_origineel, $filename, $this->DOCUMENT_ROOT . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey));
                                     }
                                 }
                             }
                             $product_arr_new[$key_p] = $update_product_images;
                         } else {
                             $product_arr_new[$key_p] = $val_p;
                         }
                     } else {
                         $product_arr_new[$key_p] = $val_p;
                     }
                 }
             }
         }
         $product_arr_new['sort_order'] = time();
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products', $product_arr_new);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
         $id_product_new = $GLOBALS['TYPO3_DB']->sql_insert_id();
         unset($product_arr_new);
         if ($id_product_new) {
             // insert tx_multishop_products_description
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_description', 'products_id=\'' . $id_product . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                 $product_arr_new = $row;
                 $product_arr_new['products_id'] = $id_product_new;
                 if (strpos($product_arr_new['products_name'], '(copy') === false) {
                     $product_arr_new['products_name'] .= ' (copy ' . $id_product_new . ')';
                 } else {
                     if (strpos($product_arr_new['products_name'], '(copy ' . $id_product . ')') !== false) {
                         $product_arr_new['products_name'] = str_replace('(copy ' . $id_product . ')', ' (copy ' . $id_product_new . ')', $product_arr_new['products_name']);
                     } else {
                         $product_arr_new['products_name'] = str_replace('(copy)', ' (copy ' . $id_product_new . ')', $product_arr_new['products_name']);
                     }
                 }
                 $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_description', $product_arr_new);
                 $res = $GLOBALS['TYPO3_DB']->sql_query($query);
             }
             // insert tx_multishop_products_attributes
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_attributes', 'products_id=\'' . $id_product . '\' and page_uid=\'' . $this->showCatalogFromPage . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) {
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                     $product_arr_new = $row;
                     $product_arr_new['products_id'] = $id_product_new;
                     $product_arr_new['page_uid'] = $this->showCatalogFromPage;
                     unset($product_arr_new['products_attributes_id']);
                     //primary key
                     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_attributes', $product_arr_new);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 }
             }
             // insert tx_multishop_specials
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_specials', 'products_id=\'' . $id_product . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) {
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                     $product_arr_new = $row;
                     $product_arr_new['products_id'] = $id_product_new;
                     unset($product_arr_new['specials_id']);
                     //primary key
                     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_specials', $product_arr_new);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 }
             }
             // insert tx_multishop_products_to_relative_products
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_to_relative_products', 'products_id=\'' . $id_product . '\' or relative_product_id = \'' . $id_product . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) {
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                     $product_arr_new = $row;
                     if ($product_arr_new['products_id'] == $id_product) {
                         $product_arr_new['products_id'] = $id_product_new;
                     } else {
                         $product_arr_new['relative_product_id'] = $id_product_new;
                     }
                     unset($product_arr_new['products_to_relative_product_id']);
                     //primary key
                     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_relative_products', $product_arr_new);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 }
             }
             // insert into tx_multishop_products_to_categories
             $insertArray = array('products_id' => $id_product_new, 'categories_id' => $target_categories_id, 'sort_order' => time(), 'page_uid' => $this->showCatalogFromPage);
             //$query=$GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_categories', $insertArray);
             //$res=$GLOBALS['TYPO3_DB']->sql_query($query);
             // create categories tree linking
             $res = tx_mslib_catalog::linkCategoriesTreeToProduct($id_product_new, $target_categories_id, $insertArray);
             if ($res) {
                 if ($this->ms['MODULES']['FLAT_DATABASE']) {
                     mslib_befe::convertProductToFlat($id_product);
                 }
             } else {
                 return false;
             }
         }
     }
 }
 function compareDatabaseAlterProductToCategoryLinking()
 {
     $p2c_records = mslib_befe::getRecords('', 'tx_multishop_products_to_categories', '', array(), '', '', '');
     foreach ($p2c_records as $p2c_record) {
         tx_mslib_catalog::linkCategoriesTreeToProduct($p2c_record['products_id'], $p2c_record['categories_id']);
     }
 }
Esempio n. 4
0
                 $insertArray['foreign_categories_id'] = $foreign_cat_id;
                 $insertArray['page_uid'] = $this->showCatalogFromPage;
                 $insertArray['foreign_page_uid'] = $page_uid;
                 $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_categories_to_categories', $insertArray);
                 $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 $has_products = mslib_fe::getProducts('', $catid);
                 if (count($has_products)) {
                     foreach ($has_products as $product_id => $product_data) {
                         $updateArray = array();
                         $updateArray['categories_id'] = $foreign_cat_id;
                         $updateArray['products_id'] = $product_id;
                         $updateArray['sort_order'] = time();
                         $updateArray['page_uid'] = $page_uid;
                         $updateArray['related_to'] = $reflector_cattree[$foreign_cat_id];
                         // create categories tree linking
                         tx_mslib_catalog::linkCategoriesTreeToProduct($product_id, $foreign_cat_id, $updateArray);
                     }
                 }
             }
         }
     }
 } else {
     if ($_REQUEST['action'] == 'edit_category') {
         // update name only on other shop
         $str = "SELECT c.categories_id from tx_multishop_categories c where c.related_to='" . $catid . "'";
         $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
         if (!$GLOBALS['TYPO3_DB']->sql_num_rows($qry)) {
             // update name only on other shop
             $str = "SELECT p2c.categories_id from tx_multishop_products_to_categories p2c where p2c.related_to='" . $catid . "' group by categories_id";
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
         }
             $product_arr_new['products_id'] = $id_product_new;
         } else {
             $product_arr_new['relative_product_id'] = $id_product_new;
         }
         unset($product_arr_new['products_to_relative_product_id']);
         //primary key
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_relative_products', $product_arr_new);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
     }
 }
 // insert into tx_multishop_products_to_categories
 $insertArray = array('products_id' => $id_product_new, 'categories_id' => $id_category, 'page_uid' => $this->showCatalogFromPage, 'sort_order' => time());
 //$query=$GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_categories', $insertArray);
 //$res=$GLOBALS['TYPO3_DB']->sql_query($query);
 // create categories tree linking
 $res = tx_mslib_catalog::linkCategoriesTreeToProduct($id_product_new, $id_category, $insertArray);
 // custom page hook that can be controlled by third-party plugin
 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/ajax_pages/copy_duplicate_product.php']['copyDuplicateProductPostHook'])) {
     $params = array('old_products_id' => &$id_product, 'products_id' => &$id_product_new);
     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/ajax_pages/copy_duplicate_product.php']['copyDuplicateProductPostHook'] as $funcRef) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
     }
 }
 // custom page hook that can be controlled by third-party plugin eof
 if ($res) {
     echo "<p>Product succesfully duplicated</p>";
     if ($this->ms['MODULES']['FLAT_DATABASE']) {
         // if the flat database module is enabled we have to sync the changes to the flat table
         mslib_befe::convertProductToFlat($id_product_new);
     }
 } else {
Esempio n. 6
0
         $updateArray['categories_id'] = $categories_id;
         $updateArray['page_uid'] = $this->showCatalogFromPage;
         if (isset($item['products_sort_order'])) {
             $updateArray['sort_order'] = $item['products_sort_order'];
         } else {
             if (is_numeric($sortOrderArray['tx_multishop_products_to_categories']['sort_order'])) {
                 $sortOrderArray['tx_multishop_products_to_categories']['sort_order'] += 1;
             } else {
                 $sortOrderArray['tx_multishop_products_to_categories']['sort_order'] = time();
             }
             $updateArray['sort_order'] = $sortOrderArray['tx_multishop_products_to_categories']['sort_order'];
         }
         /*$query=$GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_categories', $updateArray);
         		$res=$GLOBALS['TYPO3_DB']->sql_query($query);*/
         // create categories tree linking
         tx_mslib_catalog::linkCategoriesTreeToProduct($item['added_products_id'], $categories_id, $updateArray);
         $inserteditems[$categories_id][] = $item['products_name'];
     }
 }
 if ($item['products_specials_price'] and $item['products_specials_price'] < $item['products_price']) {
     // product has a specials price, lets add it
     $updateArray = array();
     $updateArray['products_id'] = $item['added_products_id'];
     $updateArray['specials_new_products_price'] = $item['products_specials_price'];
     if (strstr($updateArray['specials_new_products_price'], ",")) {
         $updateArray['specials_new_products_price'] = str_replace(",", '.', $updateArray['specials_new_products_price']);
     }
     $updateArray['specials_date_added'] = time();
     if ($item['products_special_price_expiry_date']) {
         $updateArray['expires_date'] = strtotime($item['products_special_price_expiry_date']);
     }