Replies: 3 comments
-
Hi, instead of like that: |
Beta Was this translation helpful? Give feedback.
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 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Sorry, i need to search deeper, i was sure to put an option |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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
Beta Was this translation helpful? Give feedback.
All reactions