Having a slight issue extending the product class. On each page I have an option to select a header image within the CMS. This method worked well for the Page and ProductGroup classes but wont work with the product class.
mysite/code/NicholsProduct.php:
<?php
class NicholsProduct extends Product {
static $singular_name = 'Nichols Product Page';
static $plural_name = 'Nichols Product Pages';
static $db = array(
);
static $has_one = array(
'HeaderImage' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new ImageField('HeaderImage','Header Image'),'Content');
return $fields;
}
}
class NicholsProduct_Controller extends Product_Controller {
static $singular_name = ' Nichols Product Controller';
static $plural_name = 'Nichols Product Controllers';
}
Completed a flush with no errors. Changed the behavior in the CMS to NicholsProduct now when we go to a product page we get the following error:
[User Warning] NicholsProduct_OrderItem needs to be a subclass of OrderItem
GET /florist/
Line 402 in /home/jasonmoo/public_html/nichols/ecommerce/code/control/ShoppingCart.php
Source
393 static function get_modifiers() {
394 return self::current_order()->Modifiers();
395 }
396
397 /**
398 * Get OrderItem according to product id, and coorresponding parameter filter.
399 */
400 static function get_order_item_by_buyableid($buyableID, $orderItemClassName = "OrderItem", $parameters = null ) {
401 if(!ClassInfo::is_subclass_of($orderItemClassName, "OrderItem")) {
402 user_error("$orderItemClassName needs to be a subclass of OrderItem", E_USER_WARNING);
403 }
404 $filter = self::turn_params_into_sql($parameters = null);
405 $order = self::current_order();
406 $filterString = ($filter && trim($filter) != "") ? " AND $filter" : "";
407 // NOTE: MUST HAVE THE EXACT CLASSNAME !!!!! THEREFORE INCLUDED IN WHERE PHRASE
408 return DataObject::get_one($orderItemClassName, "\"ClassName\" = '".$orderItemClassName."' AND \"OrderID\" = ".$order->ID." AND \"BuyableID\" = ".$buyableID." ". $filterString);
Can some one please point me down the correct path :)