Jump to:

2081 Posts in 1001 Topics by 452 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Add has_one and has_many to ProductGroup etc etc

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1671 Views
  • Shane Garelja
    Avatar
    Community Member
    18 Posts

    Add has_one and has_many to ProductGroup etc etc Link to this post

    Hi,

    Is it a reasonable suggestion that all modules declare the DB related statics to allow pages to be extended easily e.g. has_one, has_many - even if they are empty?

    I have just spent a fairly long time trying to figure out why I was getting an error saving ~any~ page after adding an Object Decorator for the ProductGroup page in the ecommerce module. I wanted to have an image field via a has_one relationship but then couldn't figure out why I was getting error saving all the other page types. It was obviously due to the fact ProductGroup does not declare the has_one static so the new Image relationship was being added to Page which did not have the column ImageID. Resulting in the error: Unknown column 'ImageID' in 'field list' when saving other pages.

    After adding an empty has_one static to the ProductGroup core file in ecommerce, all was well. But this obviously defeats the purpose of Object Decorators

    I realise the cause is PHP related, not Silverstripe but it would be good if this was a recommendation to all module developers (if it isn't already).

    Unless I'm completely barking up the wrong tree here and there is good reason why this isn't common practise...

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Add has_one and has_many to ProductGroup etc etc Link to this post

    All modules should include empty $has_one, $db, $many_many, $belongs_many_many and I guess $defaults and any other statics. While its not a written standard anywhere they probably all should.

    Would be great if you could create a ticket on http://open.silverstripe.com for someone to pick up on.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Add has_one and has_many to ProductGroup etc etc Link to this post

    I have been informed that in the next version of SilverStripe you will not need to declare these things on the base class's to be able to override them. Now I guess we just have to wait

  • Shane Garelja
    Avatar
    Community Member
    18 Posts

    Re: Add has_one and has_many to ProductGroup etc etc Link to this post

    Aha! That's great news. Thanks for letting us know

    1671 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.