I wanted to get a cart item which has a specific relation. What is unclear is whether to specify the relation as RelationName or RelationNameID. After needing to dive into the code with a debugger, I had to do both in different places:
Yaml config for required_fields (used by MatchObjectFilter)
Product_OrderItem:
extensions:
- MenuOrderItemExtension
required_fields:
- MenuProductSelection #not there is no 'ID' present
Inside MenuProductSelection.php:
public function getCartItem() {
return ShoppingCart::singleton()
->get($this->Product(), array(
"MenuProductSelectionID" => $this->ID //note the use of ID
));
}
This is only really a 'bug' in the API usability sense. Its also kind of related to SilverStripe framework in general. Unclear when to use ID, and when not to.
Potential solution
Maybe we just allow both uses: with and without id. This kind of customisation work is kind of edge-case anyway.
I wanted to get a cart item which has a specific relation. What is unclear is whether to specify the relation as
RelationNameorRelationNameID. After needing to dive into the code with a debugger, I had to do both in different places:Yaml config for
required_fields(used by MatchObjectFilter)Inside MenuProductSelection.php:
This is only really a 'bug' in the API usability sense. Its also kind of related to SilverStripe framework in general. Unclear when to use ID, and when not to.
Potential solution
Maybe we just allow both uses: with and without id. This kind of customisation work is kind of edge-case anyway.