7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [SOLVED ] dataobjectmanager in ecommerce
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 2106 Views |
-
[SOLVED ] dataobjectmanager in ecommerce

23 July 2009 at 8:14am Last edited: 28 July 2009 2:22am
I'm trying to add multiple images to Product Pages
I'm having trouble, whenever I try to access the images from in the CMS or in the site I get :
Website Error
There has been an errorThe website server has not been able to respond to your request.
Here is my code from the ProdImage.php
class ProdImage extends DataObject
{
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Category' => "Enum('Product, Lifestyle')"
);
static $has_one = array (
'Attachment' => 'File'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextareaField('Description'),
new DropdownField('Category','Category', singleton('ProdImage')->dbObject('Category')->enumValues()),
new FileIFrameField('Attachment')
);
}
}and from my product.php
static $has_many = array (
'ProdImage' => 'ProdImage'
);...
$manager = new ImageDataObjectManager(
$this, // Controller
'ProdImage', // Source name
'ProdImage', // Source class
'Attachment', // File name on DataObject
array(
'Name' => 'Name',
'Description' => 'Description',
'Category' => 'Category'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$manager->setFilter(
'Category', // Name of field to filter
singleton('ProdImage')->dbObject('Category')->enumValues() // Map for filter (could be $dataObject->toDropdownMap(), e.g.)
);
// If undefined, all types are allowed. Pass with or without a leading "."
// Label for the upload button in the popup
$manager->setBrowseButtonText("Upload (PNG or JPG only)");
// In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
$manager->setGridLabelField('Name');
// Plural form of the objects being managed. Used on the "Add" button.
// If left out, this defaults to [MyObjectName]s
$manager->setPluralTitle('ProdImage');
$fields->addFieldToTab("Root.Content.ProdImage", $manager);
return $fields;
I'm assuming its something simple I'm just not seeing
Thanks in Advance
-
Re: [SOLVED ] dataobjectmanager in ecommerce

23 July 2009 at 8:37am
Make sure your environment is in dev mode and you have your PHP error reporting cranked up. If you can produce a verbose error I can try to troubleshoot it for you, but "there has been an error" is not enough to go on.
-
Re: [SOLVED ] dataobjectmanager in ecommerce

23 July 2009 at 8:49am
Ok here is what I get:
User Error] Couldn't run query: SELECT `ProdImage`.*, `ProdImage`.ID, if(`ProdImage`.ClassName,`ProdImage`.ClassName,'ProdImage') AS RecordClassName FROM `ProdImage` WHERE (ParentID = '11') Unknown column 'ParentID' in 'where clause'
GET /silverstripe/new-product/?flush=1Line 400 in /Applications/MAMP/htdocs/SilverStripe/sapphire/core/model/MySQLDatabase.php
Source
391 }
392
393 function databaseError($msg, $errorLevel = E_USER_ERROR) {
394 // try to extract and format query
395 if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
396 $formatter = new SQLFormatter();
397 $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
398 }
399
400 user_error($msg, $errorLevel);
401 }
402 }
403
404 /**
405 * A result-set from a MySQL database.
406 * @package sapphire
TraceCouldn't run query: SELECT `ProdImage`.*, `ProdImage`.ID, if(`ProdImage`.ClassName,`ProdImage`.ClassName,'ProdImage') AS RecordClassName FROM `ProdImage` WHERE (ParentID = '11') Unknown column 'ParentID' in 'where clause'
Line 400 of MySQLDatabase.php
MySQLDatabase->databaseError(Couldn't run query: SELECT `ProdImage`.*, `ProdImage`.ID, if(`ProdImage`.ClassName,`ProdImage`.ClassName,'ProdImage') AS RecordClassName FROM `ProdImage` WHERE (ParentID = '11') | Unknown column 'ParentID' in 'where clause',256)
Line 102 of MySQLDatabase.php
MySQLDatabase->query(SELECT `ProdImage`.*, `ProdImage`.ID, if(`ProdImage`.ClassName,`ProdImage`.ClassName,'ProdImage') AS RecordClassName FROM `ProdImage` WHERE (ParentID = '11'),256)
Line 120 of DB.php
DB::query(SELECT `ProdImage`.*, `ProdImage`.ID, if(`ProdImage`.ClassName,`ProdImage`.ClassName,'ProdImage') AS RecordClassName FROM `ProdImage` WHERE (ParentID = '11'))
Line 426 of SQLQuery.php
SQLQuery->execute()
Line 1093 of DataObject.php
DataObject->getComponents(ProdImage)
call_user_func_array(Array,Array)
Line 504 of Object.php
Object->__call(prodimage,Array)
Product->prodimage()
call_user_func_array(Array,Array)
Line 489 of Object.php
Object->__call(ProdImage,Array)
Product_Controller->ProdImage()
call_user_func_array(Array,Array)
Line 318 of ViewableData.php
ViewableData->obj(ProdImage)
Line 579 of .cache.Applications.MAMP.htdocs.SilverStripe.ecommerce.templates.Layout.Product.ss
include(/private/var/folders/aB/aByz7rP2HuGx5L2XUu8FWU+++TI/-Tmp-/silverstripe-cache-Applications-MAMP-htdocs-silverstripe/.cache.Applications.MAMP.htdocs.SilverStripe.ecommerce.templates.Layout.Product.ss)
Line 354 of SSViewer.php
SSViewer->process(Product_Controller)
Line 346 of SSViewer.php
SSViewer->process(Product_Controller)
Line 175 of Controller.php
Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
Controller->handleRequest(HTTPRequest)
Line 29 of ModelAsController.php
ModelAsController->handleRequest(HTTPRequest)
Line 277 of Director.php
Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
Director::direct(/new-product/)
Line 118 of main.php -
Re: [SOLVED ] dataobjectmanager in ecommerce

23 July 2009 at 9:27am
You haven't set up your model properly.
static $has_one = array (
'Product' => 'Product',
'Attachment' => 'File'
); -
Re: [SOLVED ] dataobjectmanager in ecommerce

24 July 2009 at 1:34am
Thanks that fixed it, I knew it was something stupid.
Now I can't call the Image from the template. I can call the Name, Description and Category but not Attached File. I tried structuring like the example and no output. Does the template call for the ImageDataObjectManager work differently than the File?
| 2106 Views | ||
|
Page:
1
|
Go to Top |

