Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by metalines

  1. Hi, Thank you everyone, this thread has made everything work so well, but i need one last little bit of help . I have got this improvement now working for one attachment but for the life of me i cant get it to import multiple attachments. I cant understand what this explode is for? Can anyone point me in the right direction here. As far as i can tell in the column following the attachments it should just be the attachment id numbers separated by the desired multiple value separator. So whats the explode for? $tab_attachment_id_nums =explode('|',$product->attachment_id_nums); if (!Attachment::attachToProduct($product->id, $tab_attachment_id_nums)) $this->errors[] = Tools::displayError('An error occurred while saving product attachments.'); } my sample csv: 1533;attachment-manual.pdf|attachment [email protected]|attachment-manual-1;[email protected] When i import it throws up the following error: [PrestaShopException]Property Attachment->name length (39) must be between 0 and 32 at line 954 in file classes/ObjectModel.php
  2. Hi Silvioscavone, Thanks for everyone who helped on this it has made everything so easy! Silvioscavone, thanks for your improvement, I'm just implementing it in my site now and I would like to ask something about it... My current csv looks like this: field separator ; multiple value separator @ attachment file name.pdf | attachment name product-id;attachment-1.pdf|[email protected]|[email protected]|attachment-3;delete-existing-attachments; With your improvement should it now look as follows: product-id;attachment-1.pdf|[email protected]|[email protected]|attachment-3;[email protected]@attachment-id-3;delete-existing-attachments; or product-id;attachment-1.pdf|attachment-1;attachment-id-1;attachment-2.pdf|attachment-2;attachment-id-2;attachment-3.pdf|attachment-3;attachment-id-3;delete-existing-attachments; I hope what I am asking has been asked clearly and thanks in advance! Mike
  3. Is there a reason that, if you add an attachment through the back office the file name is a sha1 hash number but when i import attachments through CSV they have the actual file name and extension? Also, if product 1 and product 2 have the exact same attachment, and i set the 'delete existing attachment' column to '1', is it possible that when the product 2 is imported it deletes the attachment on product 1? There is also something else, i have noticed, if i navigate to attachment tab in BO, each attachment has only one assigned product. Mike
  4. Hi Vicky, Thank you for the reply. I am trying an import now, as follows: ;ID No;Attachment; Fingers crossed! Mike
  5. Also, the average line in my CSV is 5700 characters. Could this be a problem? Thanks Mike
  6. Hi, I did manage to get this working, eventually, due to my limited knowledge. It was a great success, but unfortunately it was short lived. HAHA! Everything looked great, CSV imported with multiple attachments per product. Was fantastic news. So i imported the first stage in my product catalog, around 300 products. At first it all looked perfect, until i noticed a product without its attachments. And then after investigating further there was a number of products that didn't have there attachments. Naturally, I started by investigation whether i had the file names slightly wrong on the CSV or if the file was actually present in the downloads folder. As it turns out, there was nothing wrong here, all files present and file names matched accordingly. I then noticed that it had successfully imported for example product 1-9 perfect, 10 with no attachments, 11-13 perfect, 14 no attachment, 15-30 perfect, 31 no attachment etc. it goes on like this with seemingly no pattern. I have tried many different things to try and identify the problem but with no success, i cannot find the fault. Further to this, strangely , if you throw all the unsuccessful lines together in a CSV and import again they all work (with the odd line deciding not to work!) Further proving that there's nothing wrong with the CSV or the files but proving that the is an intermittent problem here. It like saying "if you import the same CSV over and over, but changing the order of products in the CSV, it is completely random which lines decide not to work! Any thoughts, help, advice would be fantastic! Thanks in advance! Mike
  7. Hi, Hope i'm not pestering you! I have now implemented the code into my website, CSV imports without errors but unfortunately it does not import the attachment to the product. It doesn't seem to do anything yet. Is there something i'm missing here? Maybe something missing from the code? Thanks in advance! Mike
  8. Hi, Are you able to give me support on your coding? I have implemented it, currently i'm wondering how you got Prestashop to accept comma as value separator? I cannot get this to work, in my product import i use semi-colon as a field separator, i use @ as a multiple value separator, and, for example, in the features tab it is coded to accept colon as a separator between feature:value:id. Thanks in advance! Mike
  9. I must have got something wrong here: public function addAttachment($autodate = true, $nullValues = false) { $return = parent::add($autodate, true); return $return; } public static function addAttachmentImport($filename, $name, $description) { $attachment = new Attachment(); $languages = Language::getLanguages(); foreach ($languages as $language) $attachment->name[$language['id_lang']] = strval($name); $attachment->description[$language['id_lang']] = $description; $attachment->file = $filename; $attachment->file_name = $filename; $path_file = _PS_DOWNLOAD_DIR_.$filename; $attachment->file_size = filesize($path_file); $finfo = finfo_open(FILEINFO_MIME_TYPE); $attachment->mime = finfo_file($finfo, $path_file); $attachment->addAttachment(); return (int)$attachment->id; } public static function addAttchmentProductImport($id_product, $id_attachment) { return Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'product_attachment` (`id_attachment`, `id_product`) VALUES ('.(int)$id_attachment.', '.(int)$id_product.') '); } // Import Attached files //delete existing attachments if "delete_existing_attachments" is set to 1 if (isset($product->delete_existing_attachments)) if ((bool)$product->delete_existing_attachments) $product->deleteAttachments(); $attachments = get_object_vars($product); if (isset($attachments['attachment']) && !empty($attachments['attachment'])) foreach (explode($this->multiple_value_separator, $attachments['attachment']) as $single_attachment) { $tab_attachment = explode('|', $single_attachment); $attachment_filename = isset($tab_attachment[0]) ? $tab_attachment[0] : ''; // Create unique filename and copy original file in another file with this name $filename = sha1(microtime()); $old_path=_PS_DOWNLOAD_DIR_.$attachment_filename; $new_path=_PS_DOWNLOAD_DIR_.$filename; if (!copy($old_path, $new_path)) { echo "Copy of ".$old_path."to".$new_path." failed.\n"; } $attachment_name = isset($tab_attachment[1]) ? trim($tab_attachment[1]) : $attachment_filename ; $attachment_description = isset($tab_attachment[2]) ? trim($tab_attachment[2]) : ''; if(!empty($attachment_filename)) { $id_attachment = (int)Attachment::addAttachmentImport($filename, $attachment_name, $attachment_description); Attachment::addAttchmentProductImport($product->id, $id_attachment); Product::updateCacheAttachment($product->id); } }
  10. Hi, Your solution is exactly what were looking for, i have implemented it this morning, everything was going well unit i checked the Front Office. The downloads are on the product page (Bravo!) and have the correct title. (Bravo!) When you click to download it downloads a file that is something like: 85abc36bd15f91d5330e5caab4025d52c03075a4 (No Bravo!) Which, if you are like me it is OK as i opened it with adobe acrobat which opens the correct PDF file. However, i'm not sure this is great for my customers. The problem is the following: a) the downloaded file is not titled anything relevant, such as what the uploaded file was called. b ) there is no file extension so they cant open it unless they somehow realize they have to rename the file with .pdf at the end. any help would be appreciated. Thanks
  11. Hi, Just fixed it, it was the " that was causing the problem, removed them and imported perfectly fine, classes in the html and everything. Great!
  12. Hi, Just been having a look around and stumbled across your post, its a long shot but heres my product description, hope you can help <h2>BFT SUB EL KIT</h2><h4>Complete kit for a pair of residential industrial collective or tertiary swing gates up to a maximum of 3.5m in width or 800kg in weight each leaf.</h4><h3><span class="fa fa-tint"></span>&nbspStrong & Durable Hydraulic Motor</h3><h4>Most powerful motor for the largest gates. More durable with fewer moving parts and can easily be repaired by replacing the seals and the oil motor can be back in service for years to come. </h4><h3><span class="fa fa-diamond"></span>&nbspUltimate Choice in Aesthetical Appearance</h3><h4>This underground equipment is specifically designed so that the motor is concealed in a load bearing foundation box beneath the pivot point of your hinged swing gates giving you the very best in aesthetics while further reducing hazards by removing more trapping points above ground level. </h4><h3><span class="fa fa-cogs"></span>&nbspLCD Display</h3><h4>Control Panel with LCD display for simplified programming.</h4><h3><span class="fa fa-bolt"></span>&nbspIntensive Use</h3><h4>The motor is specifically designed for intensive use. Enjoy the comfort of an electric gate that can open and close for numerous visitors throughout the day. Particularly useful for shared entrance gates to a large number of residences. </h4><div class="inside-box-window"><div class="inside-box-window-header"><div class="inside-box-window-title"><h3>What comes in the box</h3></div></div><div class="inside-box-body"><div class="inside-box"><ul class="inside-box-row inside-box-header"><li class="inside-box-header-track"><h4>Quantity</h4></li><li class="inside-box-header-title"><h4>Item</h4></li></ul><ul class="inside-box-row inside-box-row-even"><li class="inside-box-track"><h4><li class="inside-box-track"><h4>2</h4></li><li class="inside-box-title"><h4><strong>BFT SUB EL</strong>&nbsp230v Motor's</h4></li><li class="inside-box-track"><h4>1</h4></li><li class="inside-box-title"><h4><strong>BFT RIGEL 5</strong>&nbspControl Panel</h4></li><li class="inside-box-track"><h4>2</h4></li><li class="inside-box-title"><h4><strong>BFT Mitto RB</strong>&nbsp2 Button Transmitter's</h4></li><li class="inside-box-track"><h4>1</h4></li><li class="inside-box-title"><h4><strong>BFT Desme</strong>&nbspPair of safety photocells</h4></li><li class="inside-box-track"><h4>1</h4></li><li class="inside-box-title"><h4><strong>BFT</strong>&nbspAntenna</h4></li><li class="inside-box-track"><h4>2</h4></li><li class="inside-box-title"><h4><strong>BFT FCS</strong>&nbspFoundation Box's</h4></li></ul></div></div></div> <table><tr class=models-table-top><td>Motor Models</td><td>Motor Power Supply</td><td>Mains Power Supply</td><td>Max Weight</td><td>Max Width</td><td>Max Opening Angle</td><td>Notes</td><tr><td>BFT SUB</td><td>230v</td><td>230v</td><td>800kg</td><td>1.8m</td><td>130°</td><td>Locking</td><tr><td>BFT SUB BT</td><td>24v</td><td>230v</td><td>800kg</td><td>2.5m</td><td>130°</td><td>Obstacle detection</td><tr><td>BFT SUB E</td><td>230v</td><td>230v</td><td>800kg</td><td>2.5m</td><td>130º</td><td>Reversible. Non-Locking</td><tr><td>BFT SUB EG</td><td>230v</td><td>230v</td><td>800kg</td><td>2.5m</td><td>180°</td><td>Reversible. Non-Locking</td><tr><td>BFT SUB EL</td><td>230v</td><td>230v</td><td>800kg</td><td>3.5m</td><td>130°</td><td>Reversible. Non-Locking</td><tr><td>BFT SUB ER</td><td>230v</td><td>230v</td><td>800kg</td><td>2.5m</td><td>130°</td><td>Fast motor. Reversible. Non-Locking</td><tr><td>BFT SUB G</td><td>230v</td><td>230v</td><td>800kg</td><td>1.8m</td><td>180°</td><td>Locking</td><tr><td>BFT SUB GR</td><td>230v</td><td>230v</td><td>800kg</td><td>1.8m</td><td>180°</td><td>Locking & Fast motor with Slow down on closing</td><tr><td>BFT SUB R</td><td>230v</td><td>230v</td><td>800kg</td><td>1.8m</td><td>130°</td><td>Locking & Fast motor with Slow down on closing</td></table> Please feel free to tell me im an idiot and inform me of a much simpler way to import thousands of complex products. Thanks
  13. That is brilliant! Thank you so much for your help. Works a treat. I changed the separator to comma and tested, didnt work. Changed it back to hyphen and tested it. WORKS! This is solved! Thank you!
  14. Thank you very much for coming back to me. There is a problem however, my current installation is and i have this page reload issue, but on demo.prestashop.com the version is also and the problem does not exist. How strange & frustration. Thanks
  15. I have this exact issue. Have you made any progress? Thanks in advance. Mike
  16. Just read this post looking for something else, gone to my product page and turns out i have this problem too! So... does anybody have any idea why my product page reloads when you choose an attribute but when i try to recreate the problem on demo.prestashop.com the problem does not occur? In fact their page doesn't load at all, it just instantly changes the price/picture/colour. Any ideas would be appreciated to help me track down the fault. Thanks in advance! Mike
  17. Hi Navid, Thanks for your prompt response. I'm struggling to find the improvements for 'sliders' in Prestashop This is the version we are currently running in our development environment. Our Live site is running on a previous version of Prestashop. The Advanced Search 4 module looks incredible. I have had a play with demo and it is a very very very impressive module! I will look at implementing this immediately!. Thanks again.
  18. Please can anyone help with this? I have spent weeks trying to understand layered navigation but it appears to be very complex. Is there anyway to transplant how prestashop works the weight slider to another feature/column in the DB. This would make huge improvements to our website. Please help! Many thanks
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More