CLance Posted March 27, 2014 Share Posted March 27, 2014 (edited) Hi. We have Products Category Module in Prestashop 1.6.0.5. that show products in same category. I wish to have similiar module, to bring out products of same supplier in the product page. I done duplicated and changed all the file name and variable from default productscategory module to "supplier". (In attachment) However, it still do not work. Anyone know how to make it work? Any help appreciated. Thank you.Version after Rocky's suggestion: productssupplier1.zip productssupplier.zip Edited March 28, 2014 by Lance Chan (see edit history) Link to comment Share on other sites More sharing options...
Enrique Gómez Posted March 27, 2014 Share Posted March 27, 2014 Take into account that Product doesn't have supplier_default nor the getProducts method is the same in the Category and Supplier Class. You have the $product->id_supplier with the id of the supplier. In Supplier Class the getProducts method is static so you have to call it Supplier::getProducts($product->id_supplier,$this->context->language->id, 1, 100); Link to comment Share on other sites More sharing options...
CLance Posted March 28, 2014 Author Share Posted March 28, 2014 Take into account that Product doesn't have supplier_default nor the getProducts method is the same in the Category and Supplier Class. You have the $product->id_supplier with the id of the supplier. In Supplier Class the getProducts method is static so you have to call it Supplier::getProducts($product->id_supplier,$this->context->language->id, 1, 100); I am sorry, I am new to coding. This refer to productssupplier.php, right? Link to comment Share on other sites More sharing options...
rocky Posted March 28, 2014 Share Posted March 28, 2014 Yes. Change line 130 of productssupplier.php from: $supplier_products = $supplier->getProducts($this->context->language->id, 1, 100); /* 100 products max. */ to: $supplier_products = Supplier::getProducts($product->id_supplier,$this->context->language->id, 1, 100); Link to comment Share on other sites More sharing options...
CLance Posted March 28, 2014 Author Share Posted March 28, 2014 (edited) Yes. Change line 130 of productssupplier.php from: $supplier_products = $supplier->getProducts($this->context->language->id, 1, 100); /* 100 products max. */ to: $supplier_products = Supplier::getProducts($product->id_supplier,$this->context->language->id, 1, 100); I did followed your suggestion, I install the modules, but it do not work. My product page did not show that module. http://www.eviewtrading.com/index.php?id_product=13&controller=product Any mistake that I did? (i attached corrected version in attachment of main post) I am using Prestashop 1.6.0. Edited March 28, 2014 by Lance Chan (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted March 29, 2014 Share Posted March 29, 2014 After inspecting the code, I discovered that $product->id_supplier_default doesn't exist, so I changed it to $product->id_supplier, but that variable seems to always be empty. Now that PrestaShop allows products to have multiple suppliers, I had to use the ProductSupplier class to get all the suppliers of the product. This works, but unfortunately, I can't figure out how to get the supplier that was selected as default, so I've had to get the first supplier. Hopefully, that is acceptable to you. Now you just have to fix the CSS so that the products don't wrap onto multiple lines. productssupplier.zip Link to comment Share on other sites More sharing options...
CLance Posted March 29, 2014 Author Share Posted March 29, 2014 After inspecting the code, I discovered that $product->id_supplier_default doesn't exist, so I changed it to $product->id_supplier, but that variable seems to always be empty. Now that PrestaShop allows products to have multiple suppliers, I had to use the ProductSupplier class to get all the suppliers of the product. This works, but unfortunately, I can't figure out how to get the supplier that was selected as default, so I've had to get the first supplier. Hopefully, that is acceptable to you. Now you just have to fix the CSS so that the products don't wrap onto multiple lines. Thank you, Rocky. You really helpful. For the moment, I only assign one supplier to that particular product. So, I think the module is ok for me. However, may I know the reason why css will affected? I duplicated the CSS from Product Category. Product Category has no problem with the CSS but Product Supplier has? 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