When I run xdebug for my index page it gives me an error
/bin/php -dxdebug.mode=debug -dxdebug.client_port=9003 -dxdebug.client_host=127.0.0.1 /var/www/html/thang/app/code/Smartosc/Thang/Controller/Index/Index.php
PHP Fatal error: Uncaught Error: Class "MagentoFrameworkAppActionAction" not found in /var/www/html/thang/app/code/Smartosc/Thang/Controller/Index/Index.php:5
Stack trace:
#0 {main}
thrown in /var/www/html/thang/app/code/Smartosc/Thang/Controller/Index/Index.php on line 5
Process finished with exit code 129 (interrupted by signal 1:SIGHUP)
My code in page index.php
<?php
namespace SmartoscThangControllerIndex;
use MagentoCatalogModelResourceModelCategoryCollectionFactory;
class Index extends MagentoFrameworkAppActionAction
{
protected $_pageFactory;
protected $categoryCollectionFactory;
protected $_category;
public function __construct(
MagentoCatalogModelCategory $category,
MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $pageFactory)
{
$this->categoryCollectionFactory = $categoryCollectionFactory;
$this->_category = $category;
$this->_pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
$categoryId = 5; // ID của danh mục bạn muốn hiển thị
$category = $this->_category->load($categoryId);
echo "<pre>";
print_r($category->getData());
echo "</pre>";
$collection = $this->categoryCollectionFactory->create();
$collection->addIdFilter([12,13]);
$collection->addAttributeToSelect(['name','include_in_menu']);
$collection->load();
foreach ($collection as $category) {
echo "<pre>";
$name = $category->getData('name');
$includeInMenu = $category->getData('include_in_menu');
$id = $category->getData('entity_id');
if ($name !== null && $includeInMenu !== null) {
$categoryData = [
'name' => $name,
'include_in_menu' => $includeInMenu,
'id'=>$id
];
print_r($categoryData);
}
echo "</pre>";
}
echo "Hello World 33";
exit;
}
}
I tried running comper commands, or checking the module again, but it didn’t work.i want to know why it has this error even though my paths are correct and running on the web successfully
New contributor
1167_Cao Tiến Thăng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.