Jump to content

Harmen

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by Harmen

  1. Nice example! Will soon dive deeper into this. In any case, a big thank you!
  2. Still don't get used to the hooks. Any useful links? I do still prefer the (maybe hard) way with just no hooks...
  3. Hi, The following code works for me: foreach($languages as $language) { $selected = ''; // if this page isn't viewable (active) for the language, skip it if(!$page->viewable($language)) continue; // determine the "local" URL for this language $url = $page->localUrl($language); // if language is current user's language, make it selected if($user->language->id == $language->id) { $url = "#"; $selected = " class='current'"; } // output the option tag echo "<li$selected><a href='$url'><span>$language->title</span></a></li>"; } Hope this works for you too -Harmen
  4. @adrian Found a way to get the grandchildren into the csv file. You can find my code in the attachment. But I don't get all the data from the fields like image links and more. Maybe I've missed something? I guess it doens't get all the data, because the labels are different for the categories and products -Still searching for multiple language- ProcessChildrenCsvExport.module
  5. Hey @adrian Thanks for your reply. I've asked my contractor how the csv file must be classified. He gave me an example which you can see in the attachment. There is one product in the attachment, but the same needs to happen for all products and categories. Languages are seperated per column. Each product in a row, Same for categories. I hope this helps you, I will also think for a solution in the code of the module altough I don't have that much experience with exports to csv formats. Note: With my 18 yrs I expect you're way better than me, but I will give it a try to think about it -Edit- I wrote a module to get the categories and products (and more stuff) from the prestashop database and import the data in Processwire. What would be easier, write another piece of code in my module/or new module to get the data out of the database and directly import it to a csv file, or just make a csv file from the data in the Processwire fields? Sorry for so many questions, still a bit newbie here I guess example.xlsx
  6. Hey all This module works great. But, I do have one problem. I need to export most of the data on the website to a csv, but the site is in multiple languages available. And I need all the available languages in the same csv. Is there any option to fix this in the module or are there plans for this module to add an export option for multiple languages? -Edit- The website I currently use is build like this: Products Category Product Product Etc... Category Etc. Is it possible to export a csv file containing all the categories together with the products? Something like pages and sub-pages... Thanks in advance, Harmen
  7. New version available! It is now possible to choose whether you import your products etc for as much languages as possible, or for only your default language! I also updated the part in the code for making and adding fields to PW.
  8. Just released a new version of this module! This module is now available without using the ProField : Table. The import for features is faster now you can import it to a textarea field. It is still available to import the features of the products to the ProField: Table if the user wants to.
  9. Anyone has an Prestashop DB available?
  10. ImportPagesPrestashop You can download it here: ImportPagesPrestashop With this module you can import your categories, products, features and images of the products to your new Processwire website! What does it? Once you've installed this module, a new tab will be under the Setup named Import Products from Prestashop. When you click on it, you can make connection with your Prestashop DB. After making the connection you can import first the categories, followed by products and the features and the images will be inserted in the fields of the product that is linked to these features and images. You can choose whether you import your categories et cetera in as much languages as possible or only in your default language. You can also choose to import the EAN-number and/or the products and the Reference code of the products. Requirements Only tested it so far on Processwire 3.x. Installation Download the zip file, upload it to your Processwire site and install it. Languages If you want this module to run as smooth as possible, name your languages like in the screenshot below. If you want to execute this module in dutch, download the .zip file, go to your languages tab in processwire, go to your dutch language and upload that .zip file to your site translation files. Credits to djuhari NL-Translations.zip
  11. Hi there, I am writing a module for people who want to import their products from the prestashop database to a new PW website. But if the database of the customer has another prefix then my database, they can't run the code or their needs to be a possibillity to input their own prefix. So I've added a field where you can input the prefix for the database, but then that inputted prefix needs to be set in the query. I tried the following: $categories = $prestashop->prepare(" SELECT .... ..... FROM :prefix_category c etc etc and then in the function to import the categories: $prefix = $this->session->dbPrefix; $categories = $this->get_category(); $categories->execute(array(':prefix'=>$prefix)); $categories->fetchAll(PDO::FETCH_ASSOC); But if I run the code, I get the following error: ImportPagesPrestashop: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens Does anyone have an idea how to solve this? Is it possible to make this changeable or should the customers change their prefix to the same prefix as mine? I hope someone has an idea.... (Sorry if you don't understand it. English isn't my native language).
  12. Doesn't really work. If I put your solution after the declaration of $product_page. I get at the end only 1 of all the images per product. So if there are 4, I get one. If I move it all up to the start of the function, then the PDO statement doesn't work anymore for some reason. I think I need something different. Will try your solution more extensive tomorrow. But in my first trials it doesn't work.
  13. Hey! I am working on a module that imports some images. But I have some struggles with a check. I need a check because if I hit the import button twice, I have the images double. I have the following code: protected function importImages() { $languages = wire("languages"); $images = $this->get_images(); $images->execute(array(':iso' => 'en')); $pictures = $images->fetchAll(PDO::FETCH_ASSOC); foreach ($pictures as $picture) { $id_product = $picture['id_product']; $product_page = $this->pages->get("productid=$id_product"); // ensure output formatting is off $product_page->of(false); $str_prlink = $picture['product_name']; //make sure end of string ends with alphanumeric $image_name = preg_replace('/[^a-z0-9]+\Z/i', '', $str_prlink); //echo $picture['id_product'] . '-' . $image_name . '-' . $picture['ean13'] . '.html'; $image_url = $picture['file_id'] . "/" . $image_name . '.jpg'; //echo "<br />"; $image_path = "http://www.r-go-tools.com/" . $image_url; //echo "file id:". $file; try { $product_page->images_product->add($image_path); } catch (Exception $e) { } // $product_page->of(false); $product_page->save(); } } I want to delete the images that are currently in that field, and then import the new images. How can I fix this?
  14. Ok, so I need to download both of the modules you said? Ok, thanks for the tip.
  15. Allright, will check mpdf out. They will download the pdf file and then give it out.
  16. On my website, my boss wants to put a catalog file. That isn't the problem. But since we are distributors, our customers want a catalog with their own logo. Is there any module or something like a module which can make that true? Maybe with a small in-file editor too?
  17. Hello, I want to put some data in a table field, but if I put the label of the first table field, it gives an error: Item 'feature' set to TableRows is not an allowed type Here is my code: foreach ($fetchAll as $fetch => $feature) { $productid = $feature["id_product"]; $pages = wire("pages")->get("productid=$productid"); $pages->of(false); // ensure output formatting is off $pages->Specification->feature = ($feature['name']); $pages->Specification->value = ($feature['value']); $pages->save(); } I tried to give the label other names, but it still doesn't work. How can this be solved?
  18. I'm not really used to hooks, maybe there is another option?
  19. Hey all, For my website I had to make a connection with an external DB. In that DB there are categories of products in different languages, and I want to import these categories in the languages that are available in processwire, I can do that with a very long code but I want to make it shorter. So I wrote a function to get the categories, but the different languages of the category names not, only if I insert the ISO-code hard-code. So here is my code: protected function get_category() { $languages = wire("languages"); try { $prestashp = $this->get_dbPrestashop(); foreach($languages as $language) { $iso_code= $language->name ; $categories = $prestashp->query( "SELECT l.id_lang, l.iso_code, cl.description, cl.name AS category_title, cl.id_shop, c.active, c.id_category, c.id_parent, c.position, cl.link_rewrite FROM ps_category c INNER JOIN ps_category_lang cl ON c.id_category=cl.id_category LEFT JOIN ps_lang l ON cl.id_lang=l.id_lang WHERE c.active='1' AND cl.id_shop='1' AND c.id_parent = '2' ORDER BY c.position "); } }catch(Exception $e) { $this->message('Failed to show categories. Try again later.'); return false; } return $categories; } So in the DB there is Deutsch, Dutch, English(default), Spanish, Italian. And when I edit the template the different languages of the category names need to be imported in the right tab of the field. https://gyazo.com/52a3549a8adaed2d5f44cac6dfb6d9d3 As you can see, there are language tabs above the field, and the names of the category in that language need to be insterted there. Anyone have an idea how I can fix this?
  20. Thanks! Now it works
  21. fbg13, I think your code works but I have to declare $pages. So $pages = ???? My code now looks like this: protected function importPage() { $categories = $this->get_category(); //The CSV means nothing, I modified the importCSVfiles module... $parent = $this->session->csvParent; $Template = $this->session->csvTemplate; foreach($categories as $item) { $str_catlink = $item['link_rewrite']; $category_name = preg_replace('/[^a-z0-9]+\Z/i', '', $str_catlink); //get the page if it exists $p = $pages->get("parent=$parent,title=$category_name"); if ($p->id) { // page exists $p->title = "$category_name"; $p->save(); } else { // page does not exist $np = new Page(); $np->template = $Template; $np->parent = $pages->get("$parent"); $np->title = "$category_name"; $np->save(); } } So, if I can declare the $pages I can try it. Suggestions are welcome...
  22. So, if I declare $parent in another way it will work? I hope so, but without this check if the page already exists, it works perfectly. So I think it is not the session that makes the problem... I wrote this in a module file by the way, maybe that makes sense?
  23. Hello, On my website I want to import categories from another website based on prestashop. For each categorie a new child page will be created, but if I want to import the categories again because there were some changes made in the categories in Prestashop, then the page has to be updated and not create a new page. So I tried the following: $parent = $this->session->Parent; foreach($categories as $item) { //make sure end of string ends with alphanumeric $str_catlink = $item['link_rewrite']; $category_name = preg_replace('/[^a-z0-9]+\Z/i', '', $str_catlink); // see if we already have this item $page = $parent->child("name=($category_name)"); // if we don't have this item already then create it if(!$page->id) { $page = new Page(); //etc etc etc But if I want to import the same categories now, there is an error: Call to a member function child() on a non-object. How can this be solved? Does anyone have an idea?
×
×
  • Create New...