Open samthejarvis opened 10 years ago
Hi Sam, thanks for reporting this. Not entirely sure what the issue might be, which version of Silverstripe are you using exactly? Also, do you have a code snippet?
Hi @samthejarvis, I've tested SwipeStripe with 3.1.2 and categories appear to be working for me on Product pages. Have not tried in GridField but this issue may be more closely related to GridField, at this point I'm not sure what the issue might be - could be a good idea to ask on IRC or the forums. Will close for now.
Getting this same error when trying to manage a Product to Product relationship with GridField. Removing the searchable_fields from ProductCategory_Extension fixed it.
Yeah we have had this problem as well, I've also had to remove the searchable fields. @frankmullenger can you reopen this one?
Guess this needs a little more investigation :smile:
+1 I'm getting this too
It appears to be an issue with the ProductCategory_Extension::$searchable_fields
It works if I change it to:
public static $searchable_fields = array(
- 'Category' => array(
+ 'ProductCategories.Title' => array(
'field' => 'TextField',
'filter' => 'ProductCategory_SearchFilter',
'title' => 'Category'
)
);
Edit: You can replicate this by setting up a many_many
with a Product
and some other DataObject
and the automatic CMSFields that are generated cause the error
A very nasty workaround in the mean-time is:
mysite/_config.php
$searchableFields = Config::inst()->get('Product', 'searchable_fields');
$searchableFields['ProductCategories.Title'] = $searchableFields['Category'];
unset($searchableFields['Category']);
Config::inst()->remove('Product', 'searchable_fields');
Config::inst()->update('Product', 'searchable_fields', $searchableFields);
unset($searchableFields);
This "fix" actually causes another problem with the GridFieldAddExistingAutocompleter
.
So if you want to use the GridFieldAddExistingAutocompleter
to relate Products to another object the SQL query generated has no "from" clause defined.
This is something to do with the apply
function in ProductCategory_SearchFilter
as it's using SiteTree_Live
and doing an inner join. This appears to be knocking the SiteTree
table out of the from clause and into a join.
When I do this in my config, it all works as expected:
$searchableFields = Config::inst()->get('Product', 'searchable_fields');
//$searchableFields['ProductCategories.Title'] = $searchableFields['Category'];
unset($searchableFields['Category']);
Config::inst()->remove('Product', 'searchable_fields');
Config::inst()->update('Product', 'searchable_fields', $searchableFields);
unset($searchableFields);
We should also get https://github.com/swipestripe/silverstripe-swipestripe-category/pull/1 merged into the 2.1 branch, as well as change the public declarations within the DataExtension to private.
"You can replicate this by setting up a many_many with a Product and some other DataObject and the automatic CMSFields that are generated cause the error" - I still couldn't replicate for some reason, does anyone have some boilerplate code for replicating this issue?
@frankmullenger
class Material extends DataObject {
private static
$db = array(
'Title' => 'Varchar(255)',
),
$many_many = array(
'Products' => 'Product',
);
}
class ProductExtension extends DataExtension {
private static $belongs_many_many = array(
'Materials' => 'Material',
);
}
This is the basic idea. If you go to the CMS to create a Material and then try to use the auto complete field on the grid for managing the Material -> Product relation it will error.
I am getting same error here, sample code from @dhensby , SS 3.1.5. Is it able to fix?
Latest SS3.1, apparent in fresh installs w/ latest categories module Using a GridField to manage a relation between a Page and Product, getting:
Fatal error: Call to a member function stat() on a non-object in C:\wamp\www\framework\model\DataObject.php on line 3226
Removing the searchable_fields from ProductCategory_Extension fixed this as calling ->relObject('Category') on a Product returns null, can't figure out why.
Changing 'Category' in searchable_fields to 'ProductCategories' (the actual name of the belongs_many_many relation) throws the same error.
Any ideas?