Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 988

Joomla! 5.x Coding • Using bootComponent + createModel via com_ajax

$
0
0
Hello,

I have a custom-built search module where I want to use an existing component's model to fetch data. For that, I got this from the extension's module:

Code:

$productsModel = Factory::getApplication()->bootComponent('com_customfilters')->getMVCFactory()->createModel('CustomfiltersModelProducts');$productIds = $productsModel->getProductIdsFromSearches();
When I use it in the module's main PHP file, I successfully get the model in $productsModel and $productIds.

However, the search module should use AJAX, and for that, I use com_ajax:

Code:

/index.php?option=com_ajax&module=my_ajax_search&format=json&method=searchdata&mysearchword=something&moduleid=135&language_tag=en-GB&showall=0
In my helper, there is a function named searchdataAjax, and this should use the model as I mentioned above. But in the helper, $productsModel is empty.
Factory::getApplication()->bootComponent('com_customfilters')->getMVCFactory() returns a Joomla\CMS\MVC\Factory\LegacyFactory object, but createModel('CustomfiltersModelProducts') returns nothing. This only happens when I use com_ajax.

Do I need to load something else, or did I miss something?

Statistics: Posted by sandomatyas — Thu Sep 19, 2024 11:04 am



Viewing all articles
Browse latest Browse all 988

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>