alvin_presta Posted July 18, 2014 Share Posted July 18, 2014 I needed advise on how to go about with a project which i am doing for myself.Its gonna be a site like groupon, so basically i want a state selection option at the beginning and then once the user selects the state all products of that particular state should be visible on the page. Such as http://www.askme.com/delhi I am confused of how to go about with this. 1.Should I create each state as a category and then add food,travel,shopping as subcategories(if this is done i will have to repeat the process of adding categories for each state) 2.Adding state as attribute(for this i have no clue about which classes or function to modify) Please help me how to go about with this, I would be greatfull to you.I am new to this framework so finding it difficult adapting to it. I was forced to post into this forum as i could not find any solution online. Link to comment Share on other sites More sharing options...
bellini13 Posted July 19, 2014 Share Posted July 19, 2014 if you use an attribute for the state, why do you believe you would have to modify classes or functions? Link to comment Share on other sites More sharing options...
alvin_presta Posted July 19, 2014 Author Share Posted July 19, 2014 @bellini13 sorry its a typo, I meant if I add state as an attribute to the product, how could i modify the mysql query to fetch the necessary product with that attribute, and where do i do that, as I would have to create a state drop down in the fontend, and would also be necessary to filter the products by the state attribute in the backend. I guess ill have to create a custom module, any help/resource or advice regards to this would be of great help. Link to comment Share on other sites More sharing options...
bellini13 Posted July 20, 2014 Share Posted July 20, 2014 Ok, so let's say we create a new Attribute Group called "State", and this new group has the ID 4. Within this "State" attribute group, we then add values for all the various states. In my test, I add New York and California. I can see that Prestashop assigns attribute Id for this values. For me, NY is 25 and CA is 26 (this would likely be different for you, so make sure you check that) Now I will create 2 test products and assign one product to New York, and the other to California. You do this using the products combination generator. Test Product 1 = NY Test Product 2 = CA So if I were to search for products in NY, I should get Test Product 1. And in CA I would get Test Product 2 In my query for NY I am saying "locate any products who are associated to attribute 25", and in CA I am saying "locate any products who are associated to attribute 26" So if I am looking for products for NY, I could write a query like this select p.*, pl.name from ps_product p LEFT JOIN `ps_product_lang` pl ON (p.`id_product` = pl.`id_product`) LEFT JOIN `ps_product_attribute` pa ON (pa.`id_product` = p.`id_product`) LEFT JOIN `ps_product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`) where pac.id_attribute = 25 and pl.id_lang = 1 If I am looking for products for CA, I could write a query like this select p.*, pl.name from ps_product p LEFT JOIN `ps_product_lang` pl ON (p.`id_product` = pl.`id_product`) LEFT JOIN `ps_product_attribute` pa ON (pa.`id_product` = p.`id_product`) LEFT JOIN `ps_product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`) where pac.id_attribute = 26 and pl.id_lang = 1 I'm giving you the basics here so that you have something to build on. I cannot write a complete solution for you here, so if you are really looking to do this yourself you should make the attempt and if you hit a road block, then come back showing the issue and your code and see if you can get assistance. Otherwise you might be better off looking to hire someone to create this for you. 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