Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Activity

Recent Profile Visitors

5,630,507 profile views

thijsvk's Achievements


Newbie (1/14)




Community Answers

  1. Hmm, I'm still inclined to think that it might have something to do with the permissions, that echo doesn't work because the php file is not actually executed. Unfortunately, I'm rather limited in my knowledge. Might be an idea to ask someone like Vekia or ElPatron to have a look.
  2. Are the products set to have the quantities entered manually? Also, what are the chmod settings on the files? It could be that they don't have the right permissions to be executed
  3. Have you tested it with the path set in the script? $remote_csv_file = './scriptsActualizacion/uno.csv'; In theory you shouldn't have to if they're in the same location, but theory...
  4. Did you actually set a path to your CSV file, or is it set exactly as you posted?
  5. Hi all, sorry for the delay in replying, holidays and all that. Happy Holidays!!! Only just got back to the office, and really shouldn't be here, damn holiday flu. Glad everything is working out for you TACS, in my experience it usually is a bit of a pain to figure out and adjust someone else's code, or that might just be me. Yes, I use comma separation, but you can use any delimiter really, as long as you change it in line 32. thrillmetoo I will upload the macro files as soon as I have time to sanitize them, I have some end of year dead lines, so it will probably be next week before I get around to it. Again, I can't really take credit for this, other than finding it and sharing it here, but it is nice to see it being beneficial to others
  6. Hi ken-bcn, you have a few options if I understand you correctly. Correct me if I'm wrong, but you have different suppliers, and you don't want the quantities to be set to zero. Well, if the script works for you as is, without having to reset to zero, then you can just comment it out, so it doesn't run, just put // in front of each line from '//RESET CYCLE' to '//END'. Do you have stock information from all of your suppliers? If so, you can just use the solution above. Make a master excel stock file, put all the products from all of your suppliers in the first sheet, and then create separate sheets for each of your suppliers and populate them using the import function. Create/record a macro that updates all the different sheets and again with Vlookup, the quantities on the first sheet will automatically update as well. If you want you can put a button on that first sheet so that if you click it, it will call the macro and run the updates. You can then export the first sheet using the stockupdatemacro.xls (make sure you incorporate running the update macro in your stock workbook. That should do it, everything will run as it should in one go. Alternatively, you can take the original process and use it to set up individual cronjobs for each of your suppliers. Each cronjob will then update an individual supplier and its products. Good luck!!!
  7. Hi TACS, thanks for the comments, I know, Notepad++ is awesome, it never occurred to me to use it for this exercise though, I'll have to look into that. with regards to the excess products, If I remember correctly, it will add them, but they won't show up on the front end. However, I prefer to keep the DB clean. For me, the simplest solution is to have all your products in an excel sheet (product column and quantity column, in the same workbook, start another sheet, and import the csv file from your supplier in that sheet. Using Vlookup, you can then have the first sheet check the available quantities for just your products. When you create the (new) macro template, you can record it to update the quantities, and then export the first sheet as the stock csv which will be uploaded.
  8. Hey TACS, it's not that hard really, just follow these steps: Prepare your csv upload, if you are lucky, then you can just use the information as provided by your supplier, otherwise you will need do some more work. Assuming your supplier does not send you a csv file with just 'product_reference' and 'quantity', you will need to create an excel file with a macro that will extract that information and copy it to a new file, and save that file as a csv. Basically, open a new excel file > record macro > while recording, open the supplier file, select the columns you need, copy them, open a new excel file, paste the columns, save as something like 'stockinfo.csv' in a location of your choice > go back to the first excel file and click 'stop recording to finish the macro. Save this file as stockupdatemacro.xls(x). Add a job to Windows System Scheduler to run that macro file as often as you need, to regenerate the CSV file. You will need a program like AutoFTP to automatically (scheduled) upload the CSV file to your webhost, in a location of your choice. Copy the php cron job above and save it as something like cronstockupdate.php and upload this to a location of your choice on your webhost (remember where you upload the files). The cron task manager doesn't really work, so your best bet is to use a site like easycron.com and set it to run the cronjob that you created (you need the location of the cron job for this) and then set it to run as often as needed. And that's it really. If you are able to download the supplier stock info through ftp, you can automate that as well, so it downloads it when you tell it to, and then have the macro job run a few minutes afterwards, followed by the AutoFTP upload a few minutes after that, and then the cronjob a few minutes after that.
  9. Yay Aftership support!! They sorted out my issue. Before I gave them (limited) access to the BO and FTP, I reverted all my changes, so they could start with a clean slate. We had some issues with sending the credentials, but once they had those, they fixed it within a few days.
  10. I wish it was that easy . No "Move JavaScript" is not active, and the situation is the same on both Chrome and FF on multiple devices on multiple networks. I might just have to look into the tracking url.
  11. Somehow adding the iframe made the tracking button appear. Not sure how or what, but of course that means that I don't need the iframe anymore. Unfortunately, removing it, makes the button dissapear again so I've set the width of the iframe to 100% and the height to 1px, giving me a nice line. Confused. Edit: For !"£$%^&*()_ sake, the button is displayed now but in FireFox only! AAAARRRRGGGHHH!!!!! Edit (again); it seems it's not browser related, the button has once again dissapeared. Edit (yes, again): I'm starting to think that it has something to do with Aftership's site/back end. After more mesing around, I managed to get the button back, both in Chrome and FF, only for it to disappear again. I decided not to make any changes to the code, and just refresh the page, a lot, a lot lot. And all of a sudden the button appears again.
  12. Same problem here. Moving the literal tags inside the script didn't help either. Aftership have asked for store admin access, which I'm rather reluctant to give. it seems rather pointless to me anyway, since you need to edit the tpl files on the server, so having a look in the BO would make no difference, right? Unless I'm missing something of course (not unlikely frankly). So yes, still looking for a solution. And the information is actually present on the page, just not displayed <td class="footable-last-column"> <span class="shipping_number_show"> <div id="as-root"></div><script>/* <![CDATA[ */;(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if(e.getElementById(n))return;r=e.createElement(t);r.id=n;r.src="//button.aftership.com/all.js";i.parentNode.insertBefore(r,i)})(document,"script","aftership-jssdk");/* ]]> */</script> <div data-tracking-number="1Z31Y1Y90496427607" data-size="large" data-domain="track.aftership.com" class="as-track-button"></div> </span></td> Edit: After pointing out that BO access would be of no use, they have now asked for FTP access as well.
  13. This is my solution on (cross post). My knowledge is limited, so the more people look at it, and give input the better.
  14. SORTED!!!! The problem was that the reset to zero code didn't execute properly / at all. Whether this had to do with the location within the rest of the code, I have no idea. This resulted in the quantities in the csv file being added to the quantities present in the DB, rather than overwriting them (only for product combination quantities) So after messing with it for several hours, I managed to correct the code, well to execute as intended with the desired result. Not by writing code or anything, don't have the knowledge (not enough time to learn really, and yes, it is rather essential, but tell it to my boss). Below is the entire cron job php code, for use with a csv file consisting of two columns: 'reference' and 'quantity'. The code resets all the quantities in the DB to zero first, and then updates the DB with the quantities from the DB. Of course, the csv needs to be uploaded to the defined location, we use Auto FTP Manager for that. So, if you get a daily csv file with product quantities from your supplier, this would be the way to have 'live' stock information on your site (depending on the frequency with which you receive the information from your supplier(s)). <?php // PRESTASHOP SETTINGS FILE require_once ('../config/settings.inc.php'); // REMOTE CSV FILE (CUSTOMIZE YOURCSVFILEPATH, CAN BE AN URL OR A LOCAL PATH) $remote_csv_file = '../upload/stock/XXXXXX.csv'; //MY PATH; CHANGE TO YOUR NEED, SAME FOR THE FILE NAME // DB CONNECTION (CUSTOMIZE YOURDBHOSTNAME AND YOURDBPORT) $db = new PDO("mysql:host=localhost;port=3306;dbname="._DB_NAME_."", _DB_USER_, _DB_PASSWD_); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); set_time_limit(600); // RESET CYCLE //START $default_qta = 0; $updateAll = $db->prepare("update "._DB_PREFIX_."product SET quantity = :default_qta"); $updateAll->execute(array(':default_qta'=>$default_qta)); $updateAll = $db->prepare("update "._DB_PREFIX_."product_attribute SET quantity = :default_qta"); $updateAll->execute(array(':default_qta'=>$default_qta)); $updateAll = $db->prepare("update "._DB_PREFIX_."stock_available SET quantity = :default_qta"); $updateAll->execute(array(':default_qta'=>$default_qta)); // END // MAIN CYCLE $row_num = 0; if (($handle = fopen($remote_csv_file, "r")) !== false) { while (($data = fgetcsv($handle, 1000, ",")) !== false) { $row_num++; if ($row_num == 1) { // SKIP FIRST LINE (HEADER) continue; } if ($data[0] == '' || !is_numeric($data[1])) { // SKIP EMPTY VALUES continue; } // INPUT SANITIZATION //$reference =':reference'; //$quantity =':quantity'; $reference = trim($data[0]); $quantity = ($data[1] >= 0) ? $data[1] : 0; try { $res4 = $db->prepare("SELECT id_product, id_product_attribute from "._DB_PREFIX_."product_attribute WHERE reference = :reference"); $res4->execute(array(':reference'=>$reference)); if ($res4->rowCount() > 0) { // IT'S A PRODUCT COMBINATION $row4 = $res4->fetch(); $res = $db->prepare("update "._DB_PREFIX_."stock_available set quantity = :q where id_product_attribute = :id_product_attribute"); $res->execute(array(':q'=>$quantity, ':id_product_attribute'=>$row4['id_product_attribute'])); $res = $db->prepare("update "._DB_PREFIX_."product_attribute set quantity = :q where id_product_attribute = :id_product_attribute"); $res->execute(array(':q'=>$quantity, ':id_product_attribute'=>$row4['id_product_attribute'])); $res = $db->prepare("update "._DB_PREFIX_."stock_available set quantity = quantity + :q where id_product = :id_product and id_product_attribute = 0"); $res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product'])); $res = $db->prepare("update "._DB_PREFIX_."product set quantity = quantity + :q where id_product = :id_product"); $res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product'])); } else { // IT'S A SIMPLE PRODUCT $res4 = $db->prepare("SELECT id_product from "._DB_PREFIX_."product WHERE reference = :reference"); $res4->execute(array(':reference'=>$reference)); if ($res4->rowCount() > 0) { $row4 = $res4->fetch(); $res = $db->prepare("update "._DB_PREFIX_."stock_available set quantity = :q where id_product = :id_product and id_product_attribute = 0"); $res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product'])); $res = $db->prepare("update "._DB_PREFIX_."product set quantity = :q where id_product = :id_product"); $res->execute(array(':q'=>$quantity, ':id_product'=>$row4['id_product'])); } } } catch (PDOException $e) { echo 'Sql Error: '. $e->getMessage() .'<br /><br />'; } } fclose($handle); } ?> It's impossible for me to take real credit for this, since I can't code, if it hadn't been for the original solution and comments here I would still be stuck
  • Create New...

Important Information

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