37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\ImageManager\Model\ResourceModel\Image;
|
|
|
|
use Esun\ImageManager\Model\Image;
|
|
use Esun\ImageManager\Model\ResourceModel\Image as ImageResource;
|
|
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
|
|
|
class Collection extends AbstractCollection
|
|
{
|
|
protected function _construct(): void
|
|
{
|
|
$this->_init(Image::class, ImageResource::class);
|
|
}
|
|
|
|
protected function _initSelect()
|
|
{
|
|
parent::_initSelect();
|
|
$this->getSelect()->joinLeft(
|
|
['category' => $this->getTable('esun_image_category')],
|
|
'main_table.category_id = category.category_id',
|
|
['category_name' => 'name']
|
|
);
|
|
$this->addFilterToMap('image_id', 'main_table.image_id');
|
|
$this->addFilterToMap('title', 'main_table.title');
|
|
$this->addFilterToMap('category_id', 'main_table.category_id');
|
|
$this->addFilterToMap('category_name', 'category.name');
|
|
$this->addFilterToMap('status', 'main_table.status');
|
|
$this->addFilterToMap('sort_order', 'main_table.sort_order');
|
|
$this->addFilterToMap('created_at', 'main_table.created_at');
|
|
$this->addFilterToMap('updated_at', 'main_table.updated_at');
|
|
|
|
return $this;
|
|
}
|
|
}
|