Share » Forums » Developer » Datatype to handle product options

Datatype to handle product options

Datatype to handle product options

Monday 01 December 2003 2:00:10 pm - 34 replies

Author Message

Eirik Alfstad Johansen

Monday 08 December 2003 10:40:47 am

Hi guys.

While creating overrides for the various shop templates, I accidently came across some code in the default shop/confirmorder.tpl file which mentioned product options. Backtracking this to the basket view of the shop module, I found a code-block (aprox line 95) which intention seems to be to store product options with the parameters id, value, name and additional price.

Options are seemingly fetched from the POST var eZOption, but when I include the following additional form fields in the ActionAddToBasket form:

<input type="hidden" name="eZOption[1][id]" value="Option1" />
<input type="hidden" name="eZOption[1][name]" value="Color" />
<input type="hidden" name="eZOption[1][value]" value="Blue" />
<input type="hidden" name="eZOption[1][additional_price]" value="29" />

...I get the following error:

==
Fatal error: Call to a member function on a non-object in /home/username/public_html/kernel/shop/basket.php on line 100
Fatal error: eZ publish did not finish it's request

The execution of eZ publish was abruptly ended, the debug output is present below.
==

There's also a file called ezproductcollectionitemoption.php in kernel/classes which seems to concern product options as well.

So, it seems that this is something that ez has started but not completed. Would anyone from ez be as kind as to comment on this matter?

Thanks in advance !

Sincerly,

Eirik Johansen
Netmaking AS

http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Bård Farstad

Monday 08 December 2003 12:18:51 pm

Eirik, we already have an option dartatype. If you add an option attribute to your class you will be able to enter options to products. E.g. to add color options to your product. These options can have additional prices as well.

What you need to do is to add an attribute to your class of the datatype option (ezoption). Then you can add products of this class where you define the options.

ps: what I was talking about earlier was that you now need to define options in the class definition. We could use a new datatype where you can define multiple options on object level (i.e. when you edit your product and not your class definition).

Hope this helps,

--bård

Documentation: http://ez.no/doc

Starla Carpenter

Wednesday 11 February 2004 12:45:14 pm

I set up an option datatype for my product class, but when I bring up the page as a user, it doesn't say "Add to basket." So I added a price field, left it at 0 for the item; it now does have the "Add to basket" button, and when I add the new product to basket, it DOES get the correct price (that is, from the option field).

So how do I get it to recognize this as a shop item without an explicit price field?!?

Thanks in advance,
-Starla

Eirik Alfstad Johansen

Wednesday 11 February 2004 12:56:51 pm

Hi Starla,

I don't think you can. Unless I'm mistaking, including a class attribute built upon the price datatype is the only way to make ezp aware that we are talking about a product.

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

hannes petursson

Monday 15 March 2004 4:03:32 am

Hi,
Is there any news on this topic? I'm designing a website that is planning to sell mattresses. The mattresses are in different size and the price depends on the size. So I need to have option to select size and the price depends on what is selected. Has anyone solved this limitation or is there any workaround?
Hannes

Eirik Alfstad Johansen

Monday 15 March 2004 4:26:30 am

Hi Hannes,

Have you tried using the option datatype. It sounds like that might cover your needs.

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

hannes petursson

Monday 15 March 2004 5:35:51 am

As I understand the option datatype it only works on class level isn&#8217;t? There is no way to change the options for each product.
Hannes

Eirik Alfstad Johansen

Monday 15 March 2004 5:44:45 am

Hi Hannes,

Though the available product options are specified at class level, one can select the desired product option when ordering the product. As mentioned, I suggest you try creating a class using the price and option datatypes to see how this works.

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

hannes petursson

Monday 15 March 2004 6:40:22 am

Hi and thanks again for your response.
In my case each product has a different options (size and price) then I have to create new class for each product or... Am I misunderstanding this?

hannes petursson

Wednesday 17 March 2004 3:41:58 am

Hi
That&#8217;s correct Erik, the option datatype does the job. Thanks.

Sandra Parente

Tuesday 31 August 2004 10:51:39 am

Hi all.

From the Workshop Notes and Comments- http://ez.no/community/news/workshop_notes - I assume that the shop support for multi-option datatype is far from being implemented in next eZp version. But is anyone working on it already or planning to do it?

Cheers.
Sandra

Sandra Parente
www.netbliss.it

Paul Forsyth

Tuesday 31 August 2004 11:07:30 am

Its already in trunk:

http://pubsvn.ez.no/websvn/listing.php?repname=nextgen&path=%2Ftrunk%2Fkernel%2Fclasses%2Fdatatypes%2Fezmultioption%2F&rev=0&sc=1

paul

Paul Forsyth

Tuesday 31 August 2004 11:11:34 am

Ah, try this:

http://pubsvn.ez.no/websvn/listing.php?repname=nextgen&
path=%2Ftrunk%2Fkernel%2Fclasses%2Fdatatypes%2Fezmultioption%2F&rev=0&sc=1

add the two lines together, removing the semi colon after 'nextgen&' to get the real url...

i've just filed a bug about this url behaviour:

http://ez.no/community/bug_reports/long_urls_have_inserted_characters_at_ez_no

paul

Edward Eliot

Friday 03 September 2004 7:33:12 am

Seems over the top to me. Wouldn't products and product_variations be enough with product_varitions being the item actually sold. I don't know the shop functionality but couldn't this be achieved with two class types. i.e. create an instance of the product class, then relate product_varations objects to it. I did this for a custom shopping cart application I developed a few years ago (www.mrflag.com - I know, terrible design, not mine!) and it seemed to offer all the flexibility I could imagine needing. If I am missing the point, apologies.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu