Jump to content

Override class/controller


Recommended Posts

Hi everybody,

I'm new in prestashop development and I need to understand how to start in the quickest way. I saw the developer's guide, and I just like to understand where I'm supposed to look at, in order to replace a behavior in a web site (that includes product selection and customization) made with prestashop, with something written indipendently.

The original web page let the user select a product, choose different settings and upload an image, then add the custom product to the cart. So there are different accesses to the database, but I have no idea of what tables are read/written to do that. It's a webpage developed by another person, and I just need to make some changes to that work.

The new web page will do more or less the same thing, but with a totally different logic.

I just need to understand if I have to make a module, to override an existing module, or probably I just need to override a class and a controller.

It is my first experience with prestashop.

I also need to import different libraries, like Jcrop, Bootstrap, Jquery and so on.

Sorry for the silly question

 

Thank you very much

Edited by rastafermo (see edit history)
Link to comment
Share on other sites

There is a method to use non-CMS pages instead? I'd like to maintain my logic and my files, so that prestashop can see just a "black box". My page will only need to get some info from prestashop DB, just like the user id, and output other info about the order and the custom options selected, so that I can add everything to the cart.

Probably it would be clear with the links to the original page, and the work in progress module.

Let me know if anybody is interested or could help me?

 

Thank you

Link to comment
Share on other sites

Hi rastaferno,

Your post #3 really encourages people to help.... Patience is an undervalued trait...

 

That said, maybe it helps to add some URL to the current page, an some quick sketch what you want to add/change, as the description is far for clear. You talk about 'the order', although you're still adding products to the cart etc. Also, mentioning the current version of PrestaShop may help.

 

So ask some to the point question what exactly you may need, and there is a chance you may get some more and useful answers...

 

pascal

Link to comment
Share on other sites

Thank you for the advice. The prestashop version is 1.4.9.

 

The original page is this one http://imaginashop.com/es/ . There is a category called "cuadros personalizados", which contains 6 different products. Every product is a different printing support, with fixed sizes, each one of them with a corresponding cost. The user is supposed to update a photo in order print it with the selected printing support and size. Then he can add it to the cart and proceed with the order.

 

The new page should be a little different, and needs to have similarities with this page http://www.defotoacuadro.com/ . The customer wants the user to upload a photo, choose between different materials, color filters, sizes, and so on. An example of what the new page should do is here http://imaginashop.com/demo/index.php

Every material has is own rule for the price evaluation. I made a class "Material.js" with some properties that every material has in common with each other, and then I made 6 classes, one for each material; in those classes are set the necessary variables useful in order to evaluate the price.

 

I think that more or less there is everything necessary in order to understand what is going on.

 

I just need to understand if I'm supposed to write an entire module, or it should be enough to override some files, like "Product.php", "ProductController.php" and something like that. Or probably there is a way that allows me to keep my code and introduce it in prestashop.

 

Thank you very much

Edited by rastafermo (see edit history)
Link to comment
Share on other sites

If I read your story, and understand it well, you just want to select one of the many combinations, like size, colour, filter, material used  and let the user upload its own picture.

If this is so, I think you can jus use combinations to create all existing combinations you need, like size X, colour Y, filter Z, material A and give it its prize. If all combinations exist, you can easily use the combination generator. If more complex combinations (don't) exist, maybe it's useful to buy some module attribute wizard pro or so. This makes creating the needed attribute combination easier.

 

I'm not sure if I missed anything that you need more than this, which may really need additional programming or adjusting. except for the way of input for the file maybe. This you can probably just do by changing the file upload as it is now. (in product.tpl, <!-- Customizable products --> section...> at it doesn't support drag and drop, and of course your layout differs from how it looks now (not just a button with 'Choose file', which opens the file selector)

 

 

Hope this helps,

pascal.

Link to comment
Share on other sites

Thank you, this is helpful indeed. The problem is that we have about 3000 possible combinations, and it's not a good practice in this case to set the price for every single combination. If tomorrow we need to update a variable that affects the price, we need to update manually 3000 of entries. 

 

We need to use our own rules to evaluate the price: I thought about override Product.php getPriceStatic or priceCalculation, but I can't understand how to do it properly. 

 

When you talk about the upload: are you telling me that in 'product.tpl' I can change the rules for the upload? Because I need drag'n'drop, I need to check file resolution (width x height), I want to allow people upload every image type they want (not only jpg, gif or png), and the images could be max 16MB (not 2MB).

 

How can I achieve this goal?

Link to comment
Share on other sites

If you need new combinations (new prices or so), when re-generating, the old ones are overwritten, so that should be possible automatically.

 

Yes, in product.tpl, you can change the way the file name is retrieved by adding your own code to support drag and drop. when the file is uploaded you could check the size of the image and see if it is according to the requirements. The max file size is probably a php limit, and can be changed in php.ini. The file types supported I would not know for sure. At the moment, only these three types are supported, nit sure how much work it is to add new ones. Maybe there's a module for that available??

 

My 2 cents,

pascal

Link to comment
Share on other sites

×
×
  • Create New...