
m33ts4k0z
Members-
Posts
11 -
Joined
-
Last visited
Profile Information
-
Location
Sweden
-
Activity
Developer
m33ts4k0z's Achievements
Newbie (1/14)
1
Reputation
-
Hello, I've created a module and everything works fine. However an issue that I noticed is that when accessing the webpage from a mobile device, my module appears in the website with a + next to it but when I press it nothing happens unlike all the other built in modules tha properly expand. Can I have some guidance on how to add the javascript or css in order for it to work properly? Any help would be much appreciated. Thanks in advance. PS: Website URL: http://www.myfone.se EDIT: Well, all that was needed was to add a class to the block title: <h4 class="title_block"> then the + symbol works fine. Cheers
-
Create Forms with more than 1 submit buttons
m33ts4k0z replied to m33ts4k0z's topic in Core developers
Thanks for your answer. I know how to create a form with raw code but I was just wondering if there was a class that could create such a multi-submit form programatically. Thanks anyway for your reply. -
Hello, I need to create a form in the back office in a AdminTab that I created for my module. I succeeded creating the form using the Helper class but I need to add more than 1 submit buttons into the form. Any suggestions on a way to do that? Thanks in advance!
-
Well answering my own question. I found a solution to this that satisfied me a lot. What I simply did was to use session variables that I kept the category name and then I injected it into the product name inside the orderdetail.php I have also modified the ajax script to include products by typing the first letters of the category name and that works great too. Also I modified the find() function so it would return products that exist in the search category and finally with some tpl editing I can fake the product name by adding the category next to it. This is partucullary helpful for anyone who wants to have category name but arent able to since prestashop only uses the default category in product links. Below are the most significant snippets of my code in case anyone is interested: on classes/search.php on line 218, add after: $category_search = 'SELECT id_product FROM '._DB_PREFIX_.'category_product WHERE id_category IN (SELECT id_category FROM '._DB_PREFIX_.'category_lang WHERE name LIKE '.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' ).')'; $category_name_search = 'SELECT name FROM '._DB_PREFIX_.'category_lang WHERE name LIKE '.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' ); $sql_category = 'SELECT id_category FROM '._DB_PREFIX_.'category_lang WHERE name LIKE'.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' ); search for: foreach ($intersect_array as $query) replace the whole foreach loop with the following code: foreach ($intersect_array as $query) { $eligible_products2 = array(); if(count($db->executeS($query)) > 0) { foreach ($db->executeS($query) as $row) $eligible_products2[] = $row['id_product']; } else { foreach ($db->executeS($category_search) as $row) $eligible_products2[] = $row['id_product']; session_start(); $_SESSION['actual_category_search'] = $db->getValue($category_name_search); $_SESSION['is_search'] = true; } $eligible_products = array_intersect($eligible_products, $eligible_products2); if (!count($eligible_products)) return ($ajax ? array() : array('total' => 0, 'result' => array())); } search for: if ($ajax) replace the whole if statement with: if ($ajax) { $sql = 'SELECT DISTINCT p.id_product, pl.name pname, cl.name cname, cl.link_rewrite crewrite, pl.link_rewrite prewrite '.$score.' FROM '._DB_PREFIX_.'product p INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON ( p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').' ) '.Shop::addSqlAssociation('product', 'p').' INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON ( cl.`id_category` IN ('.$sql_category.') AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').' ) WHERE p.`id_product` '.$product_pool.' ORDER BY position DESC LIMIT 10'; return $db->executeS($sql); } By making these modifications you achieved that both the ajax search and the normal search work by typing the category name. The results will display products that are under the category typed. Also you created session variables that will keep the category name until you destroy,unset or replace them. Hope this helps someone.
- 5 replies
-
- 1
-
-
- default category
- change
-
(and 3 more)
Tagged with:
-
Hello, I'm using prestashop for quite some time now and I'm really happy with it. Recently I came accross a limitation that frustrates me a bit. I'm having many categories that I made by myself. In these categories I have created like 80 products that are different with each other but will be exactly the same under each of those categories. That was the fastest solution since otherwise I would have to create each of those 80 products seperately for every category and it would take ages (the categories are about 100). Now the thing is that on each order of those products, I need to know which category they were bought from. I achieved that by adding the name of the actual category in the product name by editing the orderdetails.php. That part works fine. However now we come to the interesting part. I have modified the search.php so now I can also search for products using category names and that works fine too. The problem is that the results show the default category instead of the category the name of which i searched for. As you understand the problem is that if the customer orders the product, I wont know from which category he got it from and thats really important to me. I'm using prestashop 1.5.5 Any solution, suggestions or workarounds? Everything is welcome. Thanks in advance
- 5 replies
-
- default category
- change
-
(and 3 more)
Tagged with:
-
Importing only ,,Quantities" of products via CSV
m33ts4k0z replied to Adey's topic in Ecommerce x PrestaShop [ARCHIVE BOARD]
Yes an easy solution is to go to <admin_folder>/tabs/AdminImport.php and at the very top change: public static $required_fields = array('name'); to: public static $required_fields = array(); This will no longer require the name field. However I'm having trouble updating the quantities that way. EDIT: Having looked in prestashops code, I found the issue of quantities not updating. /* If match ref is specified AND ref product AND ref product already in base, trying to update */ /* Else If id product AND id product already in base, trying to update */ if ((Tools::getValue('match_ref') == 1 && $product->reference) || ($product->id && $datas = Db::getInstance()->getRow('SELECT `date_add`, `quantity` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$product->id))) { if (isset($datas['date_add'])) { $product->date_add = pSQL($datas['date_add']); if($product->quantity <= 0) $product->quantity = pSQL($datas['quantity']); } $res = $product->update(); } In the above example, I simply added this code: if($product->quantity <= 0) Prestashop would update the quantity if reference ID matching was set during the import. If the quantity was 0 in the database, it would replace the actual quantity with 0. Now it will now longer do that. PS: I'm using Prestashop 1.4.9 but it cant be that different in newer versions. -
You fetch a product like that: XmlReader productsUpdate = XmlReader.Create(prestaShopURL + "/api/products/?display=full&filter[reference]=" + articleNumber, settings); docUpdate.Load(productsUpdate); You read the product with the url directly into the XMLReader and then you load it into an XMLDocument. Then you do your PUT method as you did above. Note that in that example I use reference number as ID and thats why I choose the product that has the specific reference number. If you dont use display=full but for example only "price" then the XMLReader will get only the price and when you return the XML file with your put method all the other values will be null thus the issue you currently have.
-
When you want to edit a resource, you need to read the whole XML file of the resource by using the GET method first. Then you need to edit the values read and finally return the edited XML. If you send only the updated information then the rest of the values not included in the PUT request will be overwritten to null. I've myself developed an app like this on C# and works pretty well however using the RESTful component to upgrade thousands of products isn't ideal as it takes a great deal of time since the web server has to receive a seperate XML file of around 65 values and then parse it and write it to the database. There is very nice example over MSDN that I cant really find at the moment. However you can use XMLReader to load the xml site from prestashop and XMLDocument to parse it and edit its values. You will find good examples all over on how to do this. EDIT: Looking at your code above, you dont need to create 2x webrequests. You can retrieve the file using XMLReader directly and then with XMLDocument you can do something like RetourXml.SelectSingleNode("/prestashop/product/quantity") = 20; Then you can directly return your edited XML.
-
Hello, I'm developing a module that will just mass update the products categories. I seek advice regarding the best way to integrate the existing category tree in my module, the one that exists when click on a product in order to update it in the back office. Is that even possible? My module is tabbed and uses a construct to read all products that exist in the "Home" category and then show them in a list. Any help which will even point me to the right direction is more than welcome. Thanks in advance
-
Hello all, I'm trying to create a new admin page. I've managed, using the tutorials, to make it display a list of the products and generally it does what I want. The problem is that I don't seem to find a proper way to add a button at the bottom of the table where it shows my products. It only shows at the header I have implemented a boolean with a save button as you will see on my code but I don't know how to use it to call a function that I'm about to write. Is there any other way or can I use my existing code to call a function on button click and also do things with the products that are chosen by the delete multi selection? Thanks in advance <?php include_once( PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminTest extends AdminTab { public function __construct() { $sql= 'TRUNCATE TABLE '._DB_PREFIX_.'fyndiq'; $sql2= 'INSERT IGNORE INTO '._DB_PREFIX_.'fyndiq (product_id,product_name,product_price)SELECT '._DB_PREFIX_.'product_lang.id_product,name,price FROM '._DB_PREFIX_.'product_lang, '._DB_PREFIX_.'product WHERE '._DB_PREFIX_.'product_lang.id_product = '._DB_PREFIX_.'product.id_product'; if (!Db::getInstance()->Execute($sql)) die('Error etc.'); if (!Db::getInstance()->Execute($sql2)) die('Error etc.'); $this->table = 'fyndiq'; $this->className = 'fyndiq'; $this->lang = false; $this->edit = false; $this->delete = true; $this->fieldsDisplay = array( 'product_id' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'product_name' => array( 'title' => $this->l('Name'), 'width' => 200), 'product_price' => array( 'title' => $this->l('Price'), 'align' => 'center', 'width' => 6) ); $this->_fieldsOptions =array('active' => array('title' => $this->l('Importera alla valda produkter till Fyndiq.se?'), 'width' => 25, 'align' => 'center', 'active' => 'true', 'type' => 'bool', 'orderby' => true)); $this->identifier = 'product_id'; parent::__construct(); } } ?>