Email sending through api and cli fail

  • Posts: 5
  • Thank you received: 1
2 weeks 6 days ago #371566

-- HikaShop version -- : 6.4.0
-- Joomla version -- : 4.4.14
-- PHP version -- : 8.2.30
-- Browser(s) name and version -- : Firefox

Hello,

Starting to do alot more api and command line processes on our site, and having issues with Hikashop sending emails. For example, I have created a custom plugin that is called via joomla cli. Command line code:

php cli/joomla.php myplugin:send_email

In my send_email function I have
<?php
		if ( ! class_exists( 'hikashop' ) ) {
			require JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php';
		}
		$order = hikashop_get( 'class.order' )->loadNotification( $order_id, 'order_status_notification' );
		if ( empty( $order->order_id ) ) {
			return;
		}
		if ( empty( $order->mail ) ) {
			return;
		}

		hikashop_get( 'class.mail' )->sendMail( $order->mail );
?>

When I run the command, I receive this error from Hika subscription:
View not found [name, type, prefix]: orderserial, cli, orderserialView
Debug:
#0 \www\administrator\components\com_hikaserial\helpers\helper.php(223): Joomla\CMS\MVC\Controller\BaseController->getView()
#1 \www\plugins\hikashop\serials\serials.php(358): hikaserial::getLayout()
#2 \www\libraries\src\Plugin\CMSPlugin.php(289): plgHikashopSerials->onAfterOrderProductsListingDisplay()
#3 \www\libraries\vendor\joomla\event\src\Dispatcher.php(486): Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}()
#4 \www\libraries\src\Application\EventAware.php(111): Joomla\Event\Dispatcher->dispatch()
.....

If I disable Hika subscription, Hikashop throws an error:
Call to undefined method Joomla\CMS\Application\ConsoleApplication::getTemplate()
Debug:
#0 \www\libraries\src\MVC\View\HtmlView.php(145): Joomla\CMS\MVC\View\HtmlView->_setPath()
#1 \www\libraries\src\MVC\Factory\LegacyFactory.php(111): Joomla\CMS\MVC\View\HtmlView->__construct()
#2 \www\libraries\src\MVC\Controller\BaseController.php(581): Joomla\CMS\MVC\Factory\LegacyFactory->createView()
#3 \www\administrator\components\com_hikashop\helpers\helper.php(2537): Joomla\CMS\MVC\Controller\BaseController->createView()
#4 \www\administrator\components\com_hikashop\helpers\helper.php(996): hikashopBridgeController->getNewView()
.....


I get more or less the same thing when I call the mail function via joomla api system. Any chance you could update the code so emails work offline?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 85581
  • Thank you received: 14006
  • MODERATOR
2 weeks 5 days ago #371573

Hi,

Thanks for your feedback. I've made a patch in HikaShop which will allow sending HikaShop emails in CLI. HikaSubscription will require a separate patch.
Can you update HikaShop and confirm that the patch fixes the problem when HikaSubscription is out of the picture ?

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 1
2 weeks 2 days ago #371630

Hi Nicolas,

Thanks for looking at this so quickly.

I can confirm, for cli command this works fine.

I also tested it with rest api, it does not quite work there. When I run it, this is the error I get:

Call to undefined method Joomla\CMS\Router\ApiRouter::build() in /libraries/src/Router/Route.php:150
Stack trace:
#0 /libraries/src/Router/Route.php(99): Joomla\CMS\Router\Route::link()
#1 /administrator/components/com_hikashop/helpers/helper.php(1229): Joomla\CMS\Router\Route::_()
#2 /administrator/components/com_hikashop/helpers/helper.php(1404): hikashop_completeLink()
#3 /administrator/components/com_hikashop/classes/order.php(2304): hikashop_contentLink()
#4 /administrator/components/com_hikashop/classes/order.php(2277): hikashopOrderClass->loadOrderNotification()
...

The APIRouter extends Joomla/Router/Router, while all the other routers extend Joomla\CMS\Router\Router, which has the build function.

I was able to get api working by updating file /administrator/components/com_hikashop/helpers/helper.php, around line 1229, from

$ret = JRoute::_($link,!$redirect);


to
$ret = JRoute::link( 'site', $link, ! $redirect );

Last edit: 2 weeks 2 days ago by seyi.

Please Log in or Create an account to join the conversation.

  • Posts: 85581
  • Thank you received: 14006
  • MODERATOR
2 weeks 2 days ago #371632

Hi,

Generating a SEFed URL so that it can be included in an email to be sent during an API call is normal and should be possible from my point of view.
The error you're reporting here is a problem in Joomla itself which, I think, should allow for this without having to change that code.

Still, I have made a patch in order to circumvent this.
Download again the install package and install it on yours and it should work.

Last edit: 2 weeks 2 days ago by nicolas.

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum