soundsystemconnection Posted December 27, 2017 Share Posted December 27, 2017 hi guys, i'm writing you cause i can't solve a problem related to the creation of new products through php in multilanguage, in few words: I want my site (presta 1.6.1.9) integrated with tecdoc-module, this integration is creating a new product in prestashop database as soon as a product is added to the cart but i'm not able to make it work for products that are added when a secondary language is selected. my problem is that when a product is added to the cart the multilanguage fields (name, short descripion, description, category, link rewrite) are created only for default language and stay empty for the secondary languages. Anothed thing is that the products can be added to the cart only if default presta language is selected but i get an error when i try to add the products to the cart with a secondary language (not default one). what i need to do is to edit the php file responsible to tecdoc-module integration with prestashop so that when a product is created all the mandatory fields will be automatically filled for all the languages (is not important the translation is enough that the mandatory multilanguage fields will be filled the same in prestashop database for each active prestashop language) but i really don't know how i'm sure that is a stupid thing but i don't know php so for me is quiet impossible to solve this problem. i will be greatful if you could give a look (i think the interested lines are about 56-67 and 118-138... many thanks in advance, Enrico p.s. i read the post: https://www.prestashop.com/forums/topic/514708-add-new-product-programmatically/ i think that is related to my problem but i don't know php so i don't know how to use this suggestion in my specific case <?if(!defined("TDM_PROLOG_INCLUDED") || TDM_PROLOG_INCLUDED!==true)die(); //define('_PS_MODE_DEV_', true); $tm=time(); require($_SERVER["DOCUMENT_ROOT"].'/config/config.inc.php'); //$sql = 'SELECT * FROM `ps_1product` WHERE `id_product` = 10 '; //$arRes = Db::getInstance()->executeS($sql); //echo '<br><pre>';print_r($arRes);echo '</pre>'; global $TDMCore; if(!$context){$context = Context::getContext();} $PS_LANG = (string)$context->language->iso_code; //Groups: //$arPsUGroups = $context->customer->getGroups(); //array of linked groups $PsDefGroup = $context->customer->id_default_group; if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; foreach($arPGID as $TDM_GID=>$CMS_GID){ if($PsDefGroup==$CMS_GID){ if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){$_SESSION['TDM_USER_GROUP']=$TDM_GID; Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);} break; } } } //Lang if($_GET['ulng']==''){ if($PS_LANG AND TDM_LANG!=$PS_LANG AND in_array($PS_LANG,$TDMCore->arLangs)){ $_SESSION['TDM_LANG']=$PS_LANG; TDMRedirect($_SERVER['REQUEST_URI']); } } if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; global $USER; $arGroups = array((int)Group::getCurrent()->id); $isAuthorisedGroup = false; foreach($arPGID as $TDM_GID=>$CMS_GID){ if(in_array($CMS_GID,$arGroups)){ $isAuthorisedGroup = true; if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){ $_SESSION['TDM_USER_GROUP']=$TDM_GID; header('Location: '.$_SERVER['REQUEST_URI']); } break; } } if (!$isAuthorisedGroup) { unset($_SESSION['TDM_USER_GROUP']); } } //Add to cart if(defined('TDM_ADD_TO_CART') AND TDM_ADD_TO_CART){ global $arCartPrice; if(is_array($arCartPrice)){ if($_REQUEST['QTY']>1){$QUANTITY=intval($_REQUEST['QTY']);}else{$QUANTITY=1;} if($arCartPrice['OPTIONS']['MINIMUM']>1 AND $QUANTITY<$arCartPrice['OPTIONS']['MINIMUM']){$QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if($QUANTITY>$arCartPrice['AVAILABLE_NUM']){$QUANTITY=$arCartPrice['AVAILABLE_NUM'];} $DefaultCategory = intval($TDMCore->arSettings["CMS_DEFCATID"]); $Price = TDMConvertPrice($arCartPrice['CURRENCY'],$TDMCore->arSettings["CMS_ADDCART_CURRENCY"],$arCartPrice['PRICE']); $DefaultTaxGroup = 1; $VAT = 1.22; $PriceVAT = round($Price/$VAT,2); $Reference = $arCartPrice['ARTICLE'].' / '.$arCartPrice['BRAND']; //Presta init $logged = $context->cookie->__get('logged'); $id_cart = $context->cookie->__get('id_cart'); $id_lang = $context->cookie->__get('id_lang'); $id_guest = $context->cookie->__get('id_guest'); $id_currency = $context->cookie->__get('id_currency'); // Add cart if no cart found if (!$id_cart){ $context->cart = new Cart(); $context->cart->id_customer = $context->customer->id; $context->cart->id_currency = $id_currency; $context->cart->add(); if($context->cart->id){ $context->cookie->id_cart = (int)$context->cart->id; } $id_cart = (int)$context->cart->id; } $doAdd="Y"; //if(!$logged>0){$doAdd="N"; $TCore->arErrorMessages[] = 'You must be <a href="/index.php?controller=my-account">logged in</a> to buy products';} //if(trim($Reference)=='' OR !$Price>0 OR !$QUANTITY>0){$doAdd="N"; $TCore->arErrorMessages[] = 'Add to cart data is missing!';} if(!$id_cart>0){$doAdd="N"; ErAdd("Your cookie <b>id_cart</b> is wrong!",1);} if(!$id_lang>0){$doAdd="N"; ErAdd("Your cookie <b>id_lang</b> is wrong!",1);} if($doAdd!="N"){ //Check avail. tecdoc item in Presta $sql = 'SELECT p.`id_product`, pl.`name` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`) WHERE pl.`id_lang` = '.$id_lang.' AND p.`price` = '.$PriceVAT.' AND p.`reference` = "'.$Reference.'" '; $arRes = Db::getInstance()->executeS($sql); if(count($arRes)>0){ $NewTID = $arRes[0]['id_product']; }else{ //Supplier data (for 1C integration) $supplierName = $arCartPrice['SUPPLIER_STOCK']; /* $supplierId = SupplierCore::getIdByName($supplierName); if(!$supplierId){ $obSupp = new SupplierCore(null,$id_lang); $obSupp->name = $supplierName; $obSupp->active = 1; $obSupp->add(); $supplierId = $obSupp->id; }*/ //echo '<br><pre>';print_r($obSupp);echo '</pre>';die(); $obProduct = new Product(false,false,$id_lang); $obProduct->id_category_default = $DefaultCategory; $obProduct->id_category = $DefaultCategory; $obProduct->redirect_type = '404'; $obProduct->unity = $arCartPrice['ADD_URL']; $obProduct->name = substr($arCartPrice['NAME'],0,128); $obProduct->description = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->description_short = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; $obProduct->price = $PriceVAT; $obProduct->show_price = 1; $obProduct->reference = $Reference; $obProduct->link_rewrite = $arCartPrice['CPID']; $obProduct->available_for_order = 1; //true $obProduct->visibility = 'none'; //both $obProduct->is_virtual = 0; $obProduct->id_tax_rules_group = 8; if(isset($arCartPrice['OPTIONS']['WEIGHT']) AND $arCartPrice['OPTIONS']['WEIGHT']>0){$obProduct->weight = round($arCartPrice['OPTIONS']['WEIGHT']/1000,2);} if(isset($arCartPrice['OPTIONS']['MINIMUM']) AND $arCartPrice['OPTIONS']['MINIMUM']>0){$obProduct->minimal_quantity = $arCartPrice['OPTIONS']['MINIMUM']; $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if(isset($arCartPrice['OPTIONS']['USED']) AND $arCartPrice['OPTIONS']['USED']>0){$obProduct->condition = 'used';} if(isset($arCartPrice['OPTIONS']['RESTORED']) AND $arCartPrice['OPTIONS']['RESTORED']>0){$obProduct->condition = 'refurbished';} //supplier //$obProduct->supplier_name = $supplierName; //$obProduct->id_supplier = $supplierId; //echo '<br><pre>';print_r($obProduct);echo '</pre>'; $obProduct->add(); if($obProduct->id>0){ $NewTID = $obProduct->id; $obProduct->addToCategories(array($DefaultCategory)); //$obProduct->setWsCategories(Array("id"=>$DefaultCategory)); //Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'category_product` (`id_category`, `id_product`, `position`) VALUES ('.$DefaultCategory.','.$NewTID.',0)'); //Add image if($arCartPrice['IMG_SRC']!='' AND $NewTID>0){ $shops = Shop::getShops(true, null, true); $image = new Image(); $image->id_product = $NewTID; $image->position = Image::getHighestPosition($NewTID)+1; $image->cover = true; // or false; if(($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo($shops); $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); if(Tools::copy($arCartPrice['IMG_SRC'], $tmpfile)){ $path = $image->getPathForCreation(); ImageManager::resize($tmpfile, $path.'.jpg'); } unlink($tmpfile); } } }else{ ErAdd("Prestashop new Item ID is false",1); } unset($obProduct); } if($NewTID>0){ if($arCartPrice['AVAILABLE_NUM']>0){StockAvailable::setQuantity($NewTID, false, $arCartPrice['AVAILABLE_NUM']);} $obCart = new Cart($id_cart); $obCart->id_lang = $id_lang; $obCart->id_currency = $id_currency; if($obCart->updateQty($QUANTITY,$NewTID)){ Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); die(); }else{ ErAdd("Prestashop Add to Cart is false. NewTID=".$NewTID.', CartID="'.$id_cart.'"', 1); } } } } } ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $_GET=Array(); $controller = new FrontController(); $tm=time(); $controller->init(); //echo 'init() '.(time()-$tm).' sec.<br>'; $tm=time(); //$controller->initContent(); //echo 'initContent() '.(time()-$tm).' sec.<br>'; $tm=time(); $controller->setMedia(); //$controller->initHeader(); $context->smarty->tpl_vars['page']->value['page_name'] = 'TDMod'; $context->smarty->tpl_vars['page']->value['meta']['title'] = TDM_TITLE; $context->smarty->tpl_vars['page']->value['meta']['description'] = TDM_DESCRIPTION; $context->smarty->tpl_vars['page']->value['meta']['keywords'] = TDM_KEYWORDS; $context->smarty->tpl_vars['page']->value['meta']['robots'] = ''; $controller->displayHeader(); //echo 'displayHeader() '.(time()-$tm).' sec.<br>'; $tm=time(); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; $controller->displayFooter(); /* $_GET=Array(); //require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ob_start(); require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $PrestaHeader = ob_get_contents(); $PrestaHeader = str_replace(array('</body>','</html>'),'',$PrestaHeader); $PrestaHeader = str_replace('id="pagenotfound"','',$PrestaHeader); $PrestaHeader = str_replace('class="pagenotfound"','',$PrestaHeader); ob_end_clean(); echo $PrestaHeader; ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; require($_SERVER["DOCUMENT_ROOT"]."/footer.php"); */ ?> Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 Which is the reason why you are adding products by php ? You can use the webservice, or you can use csv import. Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 hi, it's because is the only way to add products that are not present in prestashop database through the tecdoc-module integration (about 4 milions products). here how it works: when a customer add a product to the cart through tecdoc-module integration the product is automatically created in prestashop database and so you can continue the order with prestashop standard cart and make the payment. If the product is not created into prestashop database through php command you can't proceed with payment in prestashop cart cause the product is not existent in presta... this is the only way so that only the products that customers want to buy are created into prestashop database and all the 4.000.000 milion product stay into tecdoc database Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 Hmm I understand. Don't think this will work, because the cart of Prestashop is not on first in the coding architecture.... Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 is working perfectly if i activate only the default language, i i try to add products with languages that are not default i get an error cause mandatory fields of new products are empty. i think i should add the function: createMultiLangField into the above php for multilanguage field of new created products but i don't know how... Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 I took a look into the link you added. This is not a real help there. Prestashop works with dependencies on database. You need to feed also other tables (not only ps_products, ps_lang and ps_suppliers). You can take a look into the database structure you will find here: PS 1.6 - http://doc.prestashop.com/download/attachments/21463263/mpd16.pdf?version=1&modificationDate=1411047693000&api=v2 For PS 1.7. I don't know where it is, cause it is still in development version. Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 what do you think regarding the possibility to edit the original line: $obProduct->name = substr($arCartPrice['NAME'],0,128); as $obProduct->name = AdminImportController::createMultiLangField (substr($arCartPrice['NAME'],0,128)); but i don't know if the syntax is correct and the same for other multilanguage fields as link rewrite and short description etc... ? Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 Take a look into database scheme I've linked. Cart rules are described there too. Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 i gave a look but i can't understand why everything is working with default language and not with other active languages thanks for the precious help! Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 the problem should be on missing feed on ps_shop(group) or ps_customer, or somewhere else. You should check which tables uses lang_id's for to mount the cart rules Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 here is the debug of the error when i try to insert a product into cart with english language (default language is italian): Notice: Undefined index: ulng in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 28 Notice: Undefined index: MINIMUM in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 60 Fatal error: Uncaught exception 'PrestaShopException' with message 'Property Product->link_rewrite is empty' in /var/www/classes/ObjectModel.php:954 Stack trace: #0 /var/www/classes/ObjectModel.php(295): ObjectModelCore->validateFieldsLang() #1 /var/www/classes/ObjectModel.php(511): ObjectModelCore->getFieldsLang() #2 /var/www/classes/Product.php(530): ObjectModelCore->add(true, false) #3 /var/www/autoparts/tocms/PrestaShop.1.6.x.php(144): ProductCore->add() #4 /var/www/autoparts/index.php(0): unknown() #5 {main} thrown in /var/www/classes/ObjectModel.php on line 954 Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 Follow the error: Property Product->link_rewrite is empty Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 and how to make the link rewrite works in PrestaShop.1.6.x.php for not default languages? i know that it should be edited the php file but i don't know how php experts give me a signal ! Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 Default language is only one. You need to feed all the languages in respect before to database. If the language is not available on database, so you will be not able to use the rewriting. You should add on SQL the language as well. I'm not a coder, cannot help you with code snippets. Sorry. Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 The languages (in this case english) are active and present in prestashop database, id english language is 5 Link to comment Share on other sites More sharing options...
selectshop.at Posted December 27, 2017 Share Posted December 27, 2017 OK. but from what I understand other languages are not available ? I don't know who mounted the script you are posting here, can't you ask there ? For to add products by php to Prestashop database you will find tutorial here: https://www.youtube.com/watch?v=0Kgn6HMcUsU Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 other languages are available, active and are working in prestashop database. the tecdoc module integration is not sending link rewrite, name and other multilanguage information to prestashop if is not selected the default language. what will i need is a modification of the attached file prestashop.1.6.x.php so that the module will write to prestashop database also if english language is selected (english because is the language other than default). something like: WHATEVER IS THE LANGUAGE SELECTED when you add to cart -> create a new product in prestashop database AND FILL MULTILANGUAGES MANDATORY FIELDS but now is like this: when you add to cart -> create a new product (working only for default language) Link to comment Share on other sites More sharing options...
PhpMadman Posted December 27, 2017 Share Posted December 27, 2017 Hi. The problem is that you don't set an array on name, description and link_rewrite. I have added an foreach loop on the products, so it adds the product and sets the same texts on all languages. I also think I have fixed the undefined indexes. You can find my changes by searching for //PhpMadman in the script. Hopefully it will get you what you want, or in the right direction. I'm note sure I have the time to help any more today. <?if(!defined("TDM_PROLOG_INCLUDED") || TDM_PROLOG_INCLUDED!==true)die(); //define('_PS_MODE_DEV_', true); $tm=time(); require($_SERVER["DOCUMENT_ROOT"].'/config/config.inc.php'); //$sql = 'SELECT * FROM `ps_1product` WHERE `id_product` = 10 '; //$arRes = Db::getInstance()->executeS($sql); //echo '<br><pre>';print_r($arRes);echo '</pre>'; global $TDMCore; if(!$context){$context = Context::getContext();} $PS_LANG = (string)$context->language->iso_code; //Groups: //$arPsUGroups = $context->customer->getGroups(); //array of linked groups $PsDefGroup = $context->customer->id_default_group; if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; foreach($arPGID as $TDM_GID=>$CMS_GID){ if($PsDefGroup==$CMS_GID){ if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){$_SESSION['TDM_USER_GROUP']=$TDM_GID; Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);} break; } } } //Lang // PhpMadman // Should fix undefined index error if(!isset($_GET['ulng']) || $_GET['ulng'] == '') { // if($_GET['ulng']==''){ if($PS_LANG AND TDM_LANG!=$PS_LANG AND in_array($PS_LANG,$TDMCore->arLangs)){ $_SESSION['TDM_LANG']=$PS_LANG; TDMRedirect($_SERVER['REQUEST_URI']); } } if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; global $USER; $arGroups = array((int)Group::getCurrent()->id); $isAuthorisedGroup = false; foreach($arPGID as $TDM_GID=>$CMS_GID){ if(in_array($CMS_GID,$arGroups)){ $isAuthorisedGroup = true; if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){ $_SESSION['TDM_USER_GROUP']=$TDM_GID; header('Location: '.$_SERVER['REQUEST_URI']); } break; } } if (!$isAuthorisedGroup) { unset($_SESSION['TDM_USER_GROUP']); } } //Add to cart if(defined('TDM_ADD_TO_CART') AND TDM_ADD_TO_CART){ global $arCartPrice; if(is_array($arCartPrice)){ if($_REQUEST['QTY']>1){$QUANTITY=intval($_REQUEST['QTY']);}else{$QUANTITY=1;} // PhpMadman // Should fix undefined index if (isset($arCartPrice['OPTIONS']['MINIMUM'])) { if ($arCartPrice['OPTIONS']['MINIMUM'] > 1 AND $QUANTITY < $arCartPrice['OPTIONS']['MINIMUM']) { $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM']; } } if($arCartPrice['OPTIONS']['MINIMUM']>1 AND $QUANTITY<$arCartPrice['OPTIONS']['MINIMUM']){$QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if($QUANTITY>$arCartPrice['AVAILABLE_NUM']){$QUANTITY=$arCartPrice['AVAILABLE_NUM'];} $DefaultCategory = intval($TDMCore->arSettings["CMS_DEFCATID"]); $Price = TDMConvertPrice($arCartPrice['CURRENCY'],$TDMCore->arSettings["CMS_ADDCART_CURRENCY"],$arCartPrice['PRICE']); $DefaultTaxGroup = 1; $VAT = 1.22; $PriceVAT = round($Price/$VAT,2); $Reference = $arCartPrice['ARTICLE'].' / '.$arCartPrice['BRAND']; //Presta init $logged = $context->cookie->__get('logged'); $id_cart = $context->cookie->__get('id_cart'); $id_lang = $context->cookie->__get('id_lang'); $id_guest = $context->cookie->__get('id_guest'); $id_currency = $context->cookie->__get('id_currency'); // Add cart if no cart found if (!$id_cart){ $context->cart = new Cart(); $context->cart->id_customer = $context->customer->id; $context->cart->id_currency = $id_currency; $context->cart->add(); if($context->cart->id){ $context->cookie->id_cart = (int)$context->cart->id; } $id_cart = (int)$context->cart->id; } $doAdd="Y"; //if(!$logged>0){$doAdd="N"; $TCore->arErrorMessages[] = 'You must be <a href="/index.php?controller=my-account">logged in</a> to buy products';} //if(trim($Reference)=='' OR !$Price>0 OR !$QUANTITY>0){$doAdd="N"; $TCore->arErrorMessages[] = 'Add to cart data is missing!';} if(!$id_cart>0){$doAdd="N"; ErAdd("Your cookie <b>id_cart</b> is wrong!",1);} if(!$id_lang>0){$doAdd="N"; ErAdd("Your cookie <b>id_lang</b> is wrong!",1);} if($doAdd!="N"){ //Check avail. tecdoc item in Presta $sql = 'SELECT p.`id_product`, pl.`name` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`) WHERE pl.`id_lang` = '.$id_lang.' AND p.`price` = '.$PriceVAT.' AND p.`reference` = "'.$Reference.'" '; $arRes = Db::getInstance()->executeS($sql); if(count($arRes)>0){ $NewTID = $arRes[0]['id_product']; }else{ //Supplier data (for 1C integration) $supplierName = $arCartPrice['SUPPLIER_STOCK']; /* $supplierId = SupplierCore::getIdByName($supplierName); if(!$supplierId){ $obSupp = new SupplierCore(null,$id_lang); $obSupp->name = $supplierName; $obSupp->active = 1; $obSupp->add(); $supplierId = $obSupp->id; }*/ //echo '<br><pre>';print_r($obSupp);echo '</pre>';die(); $obProduct = new Product(false,false,$id_lang); $obProduct->id_category_default = $DefaultCategory; $obProduct->id_category = $DefaultCategory; $obProduct->redirect_type = '404'; $obProduct->unity = $arCartPrice['ADD_URL']; // $obProduct->name = substr($arCartPrice['NAME'],0,128); // $obProduct->description = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; // $obProduct->description_short = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; $obProduct->price = $PriceVAT; $obProduct->show_price = 1; $obProduct->reference = $Reference; // $obProduct->link_rewrite = $arCartPrice['CPID']; $obProduct->available_for_order = 1; //true $obProduct->visibility = 'none'; //both $obProduct->is_virtual = 0; $obProduct->id_tax_rules_group = 8; //PhpMadman // Sets same texts for all languages $languages = Language::getLanguages(); foreach($languages as $lang) { $obProduct->name[$lang] = substr($arCartPrice['NAME'],0,128); $obProduct->description[$lang] = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->link_rewrite[$lang] = $arCartPrice['CPID']; $obProduct->description_short[$lang] = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; } if(isset($arCartPrice['OPTIONS']['WEIGHT']) AND $arCartPrice['OPTIONS']['WEIGHT']>0){$obProduct->weight = round($arCartPrice['OPTIONS']['WEIGHT']/1000,2);} if(isset($arCartPrice['OPTIONS']['MINIMUM']) AND $arCartPrice['OPTIONS']['MINIMUM']>0){$obProduct->minimal_quantity = $arCartPrice['OPTIONS']['MINIMUM']; $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if(isset($arCartPrice['OPTIONS']['USED']) AND $arCartPrice['OPTIONS']['USED']>0){$obProduct->condition = 'used';} if(isset($arCartPrice['OPTIONS']['RESTORED']) AND $arCartPrice['OPTIONS']['RESTORED']>0){$obProduct->condition = 'refurbished';} //supplier //$obProduct->supplier_name = $supplierName; //$obProduct->id_supplier = $supplierId; //echo '<br><pre>';print_r($obProduct);echo '</pre>'; $obProduct->add(); if($obProduct->id>0){ $NewTID = $obProduct->id; $obProduct->addToCategories(array($DefaultCategory)); //$obProduct->setWsCategories(Array("id"=>$DefaultCategory)); //Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'category_product` (`id_category`, `id_product`, `position`) VALUES ('.$DefaultCategory.','.$NewTID.',0)'); //Add image if($arCartPrice['IMG_SRC']!='' AND $NewTID>0){ $shops = Shop::getShops(true, null, true); $image = new Image(); $image->id_product = $NewTID; $image->position = Image::getHighestPosition($NewTID)+1; $image->cover = true; // or false; if(($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo($shops); $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); if(Tools::copy($arCartPrice['IMG_SRC'], $tmpfile)){ $path = $image->getPathForCreation(); ImageManager::resize($tmpfile, $path.'.jpg'); } unlink($tmpfile); } } }else{ ErAdd("Prestashop new Item ID is false",1); } unset($obProduct); } if($NewTID>0){ if($arCartPrice['AVAILABLE_NUM']>0){StockAvailable::setQuantity($NewTID, false, $arCartPrice['AVAILABLE_NUM']);} $obCart = new Cart($id_cart); $obCart->id_lang = $id_lang; $obCart->id_currency = $id_currency; if($obCart->updateQty($QUANTITY,$NewTID)){ Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); die(); }else{ ErAdd("Prestashop Add to Cart is false. NewTID=".$NewTID.', CartID="'.$id_cart.'"', 1); } } } } } ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $_GET=Array(); $controller = new FrontController(); $tm=time(); $controller->init(); //echo 'init() '.(time()-$tm).' sec.<br>'; $tm=time(); //$controller->initContent(); //echo 'initContent() '.(time()-$tm).' sec.<br>'; $tm=time(); $controller->setMedia(); //$controller->initHeader(); $context->smarty->tpl_vars['page']->value['page_name'] = 'TDMod'; $context->smarty->tpl_vars['page']->value['meta']['title'] = TDM_TITLE; $context->smarty->tpl_vars['page']->value['meta']['description'] = TDM_DESCRIPTION; $context->smarty->tpl_vars['page']->value['meta']['keywords'] = TDM_KEYWORDS; $context->smarty->tpl_vars['page']->value['meta']['robots'] = ''; $controller->displayHeader(); //echo 'displayHeader() '.(time()-$tm).' sec.<br>'; $tm=time(); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; $controller->displayFooter(); /* $_GET=Array(); //require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ob_start(); require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $PrestaHeader = ob_get_contents(); $PrestaHeader = str_replace(array('</body>','</html>'),'',$PrestaHeader); $PrestaHeader = str_replace('id="pagenotfound"','',$PrestaHeader); $PrestaHeader = str_replace('class="pagenotfound"','',$PrestaHeader); ob_end_clean(); echo $PrestaHeader; ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; require($_SERVER["DOCUMENT_ROOT"]."/footer.php"); */ ?> Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 MANY MANY thanks for the useful answer, now it seems that i PHP is writing only with secondary language into prestashop database but not with the default one... when i try to add a product to the cart in italian language (default) i get: Notice: Undefined index: MINIMUM in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 73 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 157 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 159 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 162 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 164 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 157 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 159 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 162 Warning: Illegal offset type in /var/www/autoparts/tocms/PrestaShop.1.6.x.php on line 164 Fatal error: Uncaught exception 'PrestaShopException' with message 'Property Product->link_rewrite is empty' in /var/www/classes/ObjectModel.php:954 Stack trace: #0 /var/www/classes/ObjectModel.php(295): ObjectModelCore->validateFieldsLang() #1 /var/www/classes/ObjectModel.php(511): ObjectModelCore->getFieldsLang() #2 /var/www/classes/Product.php(530): ObjectModelCore->add(true, false) #3 /var/www/autoparts/tocms/PrestaShop.1.6.x.php(176): ProductCore->add() #4 /var/www/autoparts/index.php(0): unknown() #5 {main} thrown in /var/www/classes/ObjectModel.php on line 954 how to have both the languages (default and secondary) writing to prestashop database? thankssss you can't imagine how much time i spent on this... Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 27, 2017 Author Share Posted December 27, 2017 (edited) edit, now with PHPmadman modification i have only ONE UNDEFINED notice: the line: if($arCartPrice['OPTIONS']['MINIMUM']>1 and still the Fatal error: Uncaught exception 'PrestaShopException' with message 'Property Product->link_rewrite is empty' for added products to cart when language is not default one presta database is still editable only from the cart in default language also if i added the lines: $languages = Language::getLanguages(); foreach($languages as $lang) { $obProduct->name[$lang] = substr($arCartPrice['NAME'],0,128); $obProduct->description[$lang] = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->link_rewrite[$lang] = $arCartPrice['CPID']; $obProduct->description_short[$lang] = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; } any idea? Edited December 27, 2017 by soundsystemconnection (see edit history) Link to comment Share on other sites More sharing options...
soundsystemconnection Posted December 28, 2017 Author Share Posted December 28, 2017 i noted that if i paste the lines: $languages = Language::getLanguages(); foreach($languages as $lang) { $obProduct->name[$lang] = substr($arCartPrice['NAME'],0,128); $obProduct->description[$lang] = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->link_rewrite[$lang] = $arCartPrice['CPID']; $obProduct->description_short[$lang] = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; } Instead of having the multilanguages fields automatically filled each time that i add a product to the presta cart i'm still having the multilanguages fields filled only for default language all the other languages are empty also in the field ['NAME'] written in default language instead of having the correct name for example: DRIVE SHAFT i get DDIVE SHAFT another example: CILINDRETTO and i get CCLINDRETTO as the first letter overwrite the second one waiting for your suggestions , thankssss Link to comment Share on other sites More sharing options...
Vatson2017 Posted February 26, 2019 Share Posted February 26, 2019 Hello. I am using prestashop 1.7. I connect the module. There is a problem: not showing title, description, keywords. <?if(!defined("TDM_PROLOG_INCLUDED") || TDM_PROLOG_INCLUDED!==true)die(); //define('_PS_MODE_DEV_', true); $tm=time(); require($_SERVER["DOCUMENT_ROOT"].'/config/config.inc.php'); //$sql = 'SELECT * FROM `ps_1product` WHERE `id_product` = 10 '; //$arRes = Db::getInstance()->executeS($sql); //echo '<br><pre>';print_r($arRes);echo '</pre>'; global $TDMCore; if(!$context){$context = Context::getContext();} $PS_LANG = (string)$context->language->iso_code; //Groups: //$arPsUGroups = $context->customer->getGroups(); //array of linked groups $PsDefGroup = $context->customer->id_default_group; if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; foreach($arPGID as $TDM_GID=>$CMS_GID){ if($PsDefGroup==$CMS_GID){ if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){$_SESSION['TDM_USER_GROUP']=$TDM_GID; Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);} break; } } } //Lang // PhpMadman // Should fix undefined index error if(!isset($_GET['ulng']) || $_GET['ulng'] == '') { // if($_GET['ulng']==''){ if($PS_LANG AND TDM_LANG!=$PS_LANG AND in_array($PS_LANG,$TDMCore->arLangs)){ $_SESSION['TDM_LANG']=$PS_LANG; TDMRedirect($_SERVER['REQUEST_URI']); } } if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; global $USER; $arGroups = array((int)Group::getCurrent()->id); $isAuthorisedGroup = false; foreach($arPGID as $TDM_GID=>$CMS_GID){ if(in_array($CMS_GID,$arGroups)){ $isAuthorisedGroup = true; if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){ $_SESSION['TDM_USER_GROUP']=$TDM_GID; header('Location: '.$_SERVER['REQUEST_URI']); } break; } } if (!$isAuthorisedGroup) { unset($_SESSION['TDM_USER_GROUP']); } } //Add to cart if(defined('TDM_ADD_TO_CART') AND TDM_ADD_TO_CART){ global $arCartPrice; if(is_array($arCartPrice)){ if($_REQUEST['QTY']>1){$QUANTITY=intval($_REQUEST['QTY']);}else{$QUANTITY=1;} // PhpMadman // Should fix undefined index if (isset($arCartPrice['OPTIONS']['MINIMUM'])) { if ($arCartPrice['OPTIONS']['MINIMUM'] > 1 AND $QUANTITY < $arCartPrice['OPTIONS']['MINIMUM']) { $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM']; } } if($arCartPrice['OPTIONS']['MINIMUM']>1 AND $QUANTITY<$arCartPrice['OPTIONS']['MINIMUM']){$QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if($QUANTITY>$arCartPrice['AVAILABLE_NUM']){$QUANTITY=$arCartPrice['AVAILABLE_NUM'];} $DefaultCategory = intval($TDMCore->arSettings["CMS_DEFCATID"]); $Price = TDMConvertPrice($arCartPrice['CURRENCY'],$TDMCore->arSettings["CMS_ADDCART_CURRENCY"],$arCartPrice['PRICE']); $DefaultTaxGroup = 1; $VAT = 1.22; $PriceVAT = round($Price/$VAT,2); $Reference = $arCartPrice['ARTICLE'].' / '.$arCartPrice['BRAND']; //Presta init $logged = $context->cookie->__get('logged'); $id_cart = $context->cookie->__get('id_cart'); $id_lang = $context->cookie->__get('id_lang'); $id_guest = $context->cookie->__get('id_guest'); $id_currency = $context->cookie->__get('id_currency'); // Add cart if no cart found if (!$id_cart){ $context->cart = new Cart(); $context->cart->id_customer = $context->customer->id; $context->cart->id_currency = $id_currency; $context->cart->add(); if($context->cart->id){ $context->cookie->id_cart = (int)$context->cart->id; } $id_cart = (int)$context->cart->id; } $doAdd="Y"; //if(!$logged>0){$doAdd="N"; $TCore->arErrorMessages[] = 'You must be <a href="/index.php?controller=my-account">logged in</a> to buy products';} //if(trim($Reference)=='' OR !$Price>0 OR !$QUANTITY>0){$doAdd="N"; $TCore->arErrorMessages[] = 'Add to cart data is missing!';} if(!$id_cart>0){$doAdd="N"; ErAdd("Your cookie <b>id_cart</b> is wrong!",1);} if(!$id_lang>0){$doAdd="N"; ErAdd("Your cookie <b>id_lang</b> is wrong!",1);} if($doAdd!="N"){ //Check avail. tecdoc item in Presta $sql = 'SELECT p.`id_product`, pl.`name` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`) WHERE pl.`id_lang` = '.$id_lang.' AND p.`price` = '.$PriceVAT.' AND p.`reference` = "'.$Reference.'" '; $arRes = Db::getInstance()->executeS($sql); if(count($arRes)>0){ $NewTID = $arRes[0]['id_product']; }else{ //Supplier data (for 1C integration) $supplierName = $arCartPrice['SUPPLIER_STOCK']; /* $supplierId = SupplierCore::getIdByName($supplierName); if(!$supplierId){ $obSupp = new SupplierCore(null,$id_lang); $obSupp->name = $supplierName; $obSupp->active = 1; $obSupp->add(); $supplierId = $obSupp->id; }*/ //echo '<br><pre>';print_r($obSupp);echo '</pre>';die(); $obProduct = new Product(false,false,$id_lang); $obProduct->id_category_default = $DefaultCategory; $obProduct->id_category = $DefaultCategory; $obProduct->redirect_type = '404'; $obProduct->unity = $arCartPrice['ADD_URL']; // $obProduct->name = substr($arCartPrice['NAME'],0,128); // $obProduct->description = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; // $obProduct->description_short = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; $obProduct->price = $PriceVAT; $obProduct->show_price = 1; $obProduct->reference = $Reference; // $obProduct->link_rewrite = $arCartPrice['CPID']; $obProduct->available_for_order = 1; //true $obProduct->visibility = 'none'; //both $obProduct->is_virtual = 0; $obProduct->id_tax_rules_group = 8; //PhpMadman // Sets same texts for all languages $languages = Language::getLanguages(); foreach($languages as $lang) { $obProduct->name[$lang] = substr($arCartPrice['NAME'],0,128); $obProduct->description[$lang] = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->link_rewrite[$lang] = $arCartPrice['CPID']; $obProduct->description_short[$lang] = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; } if(isset($arCartPrice['OPTIONS']['WEIGHT']) AND $arCartPrice['OPTIONS']['WEIGHT']>0){$obProduct->weight = round($arCartPrice['OPTIONS']['WEIGHT']/1000,2);} if(isset($arCartPrice['OPTIONS']['MINIMUM']) AND $arCartPrice['OPTIONS']['MINIMUM']>0){$obProduct->minimal_quantity = $arCartPrice['OPTIONS']['MINIMUM']; $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if(isset($arCartPrice['OPTIONS']['USED']) AND $arCartPrice['OPTIONS']['USED']>0){$obProduct->condition = 'used';} if(isset($arCartPrice['OPTIONS']['RESTORED']) AND $arCartPrice['OPTIONS']['RESTORED']>0){$obProduct->condition = 'refurbished';} //supplier //$obProduct->supplier_name = $supplierName; //$obProduct->id_supplier = $supplierId; //echo '<br><pre>';print_r($obProduct);echo '</pre>'; $obProduct->add(); if($obProduct->id>0){ $NewTID = $obProduct->id; $obProduct->addToCategories(array($DefaultCategory)); //$obProduct->setWsCategories(Array("id"=>$DefaultCategory)); //Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'category_product` (`id_category`, `id_product`, `position`) VALUES ('.$DefaultCategory.','.$NewTID.',0)'); //Add image if($arCartPrice['IMG_SRC']!='' AND $NewTID>0){ $shops = Shop::getShops(true, null, true); $image = new Image(); $image->id_product = $NewTID; $image->position = Image::getHighestPosition($NewTID)+1; $image->cover = true; // or false; if(($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo($shops); $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); if(Tools::copy($arCartPrice['IMG_SRC'], $tmpfile)){ $path = $image->getPathForCreation(); ImageManager::resize($tmpfile, $path.'.jpg'); } unlink($tmpfile); } } }else{ ErAdd("Prestashop new Item ID is false",1); } unset($obProduct); } if($NewTID>0){ if($arCartPrice['AVAILABLE_NUM']>0){StockAvailable::setQuantity($NewTID, false, $arCartPrice['AVAILABLE_NUM']);} $obCart = new Cart($id_cart); $obCart->id_lang = $id_lang; $obCart->id_currency = $id_currency; if($obCart->updateQty($QUANTITY,$NewTID)){ Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); die(); }else{ ErAdd("Prestashop Add to Cart is false. NewTID=".$NewTID.', CartID="'.$id_cart.'"', 1); } } } } } ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $_GET=Array(); $controller = new FrontController(); $tm=time(); $controller->init(); //echo 'init() '.(time()-$tm).' sec.<br>'; $tm=time(); //$controller->initContent(); //echo 'initContent() '.(time()-$tm).' sec.<br>'; $tm=time(); $controller->setMedia(); //$controller->initHeader(); $context->smarty->tpl_vars['page']->value['page_name'] = 'TDMod'; $context->smarty->tpl_vars['page']->value['meta']['title'] = TDM_TITLE; $context->smarty->tpl_vars['page']->value['meta']['description'] = TDM_DESCRIPTION; $context->smarty->tpl_vars['page']->value['meta']['keywords'] = TDM_KEYWORDS; $context->smarty->tpl_vars['page']->value['meta']['robots'] = ''; $controller->displayHeader(); //echo 'displayHeader() '.(time()-$tm).' sec.<br>'; $tm=time(); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; $controller->displayFooter(); /* $_GET=Array(); //require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ob_start(); require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $PrestaHeader = ob_get_contents(); $PrestaHeader = str_replace(array('</body>','</html>'),'',$PrestaHeader); $PrestaHeader = str_replace('id="pagenotfound"','',$PrestaHeader); $PrestaHeader = str_replace('class="pagenotfound"','',$PrestaHeader); ob_end_clean(); echo $PrestaHeader; ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; require($_SERVER["DOCUMENT_ROOT"]."/footer.php"); */ ?> Link to comment Share on other sites More sharing options...
carlos.batista Posted February 20, 2020 Share Posted February 20, 2020 //PhpMadman // Sets fields to array() first otherwise don't run $obProduct->name= array(); $obProduct->description = array(); $obProduct->link_rewrite = array(); $obProduct->description_short= array(); $languages = Language::getLanguages(false,false,true); // change this ($languages = Language::getLanguages();) for this $languages = Language::getLanguages(false,false,true); // and get only the language id // if you want get translations by prestashop use this on your strings // $translator = $this->context->getTranslator(); // $string_translated =$translator->trans($your_string) ; foreach($languages as $lang) { $obProduct->name[$lang] = substr($arCartPrice['NAME'],0,128); //this is a required field $obProduct->description[$lang] = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->link_rewrite[$lang] = $arCartPrice['CPID']; //this is a required field $obProduct->description_short[$lang] = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now