Replies: 4 comments
|
Hi, instead of like that: |
0 replies
|
Hi, thanks for your answer 'blog' => [
'type' => 'selector',
'label' => 'Choose a blog post',
'collection' => 'SimpleBlogPost',
'default' => 'default value',
'selector' => '{id_simpleblog_post} - {title}'
],there si no name in SimpleBlogPost in so I used {title} public function _getCollection($id, $collectionName, $primaryField = null)
{
if ( $collectionName == 'SimpleBlogPost' ) { $primaryField = 'id_simpleblog_post'; }
$c = new \PrestaShopCollection($collectionName, $this->id_lang);
$primary = $primaryField ?? 'id_' . \Tools::strtolower($collectionName);
$object = $c->where($primary, '=', (int) $id)->getFirst();
\PrestaShopLogger::addLog($collectionName . print_r($object, true), 1, null, 'PrettyBlocks');
if (!\Validate::isLoadedObject($object)) {
return false;
}
$objectPresenter = new ObjectPresenter();
return $objectPresenter->present($object);
}$object is still empty for SimpleBlogPost |
0 replies
|
Sorry, i need to search deeper, i was sure to put an option |
0 replies
|
Hi, was this implementation included in version 3.2.0? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Hi,
I need to call a collection from a blog module that has a SimpleBlogPost class extending ObjectModel. Is this possible?
Currently, if I use the following:
Prettyblocks crashes with "Fatal error: Uncaught PrestaShopException: Field id_simpleblogpost not found in class SimpleBlogPost" in the module the primary field is id_simpleblog_post, I've added in Fieldcore->_getCollection
$c = new \PrestaShopCollection($collectionName, $this->id_lang); returns something
but $object = $c->where($primary, '=', (int) $id)->getFirst(); returns false
So is it possible to use an ObjectModel from a module on a selector field or only native prestashop ObjectModel ?
Best regards, Alice
All reactions