Like i said in the title, i dont know how the Search in Catalog work.
As far as i know, the Search is render through this code in this ui-component:
C:\xampp\htdocs\magento\vendor\magento\module-cms\view\adminhtml\ui_component\cms_page_listing.xml
<filterSearch name="fulltext"/>
And when i copy this code and paste to my ui-component, it doesn't work at all, i can render the search text box, but when i write something and push "Enter", nothing happened.
EDIT 1:
(Here is my ui-component, InstallSchema and UpgradeSchema file)
File : C:\xampp\htdocs\magento\app\code\Aht\BannerSlider\view\adminhtml\ui_component\banner_form.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">banner_form.banner_form_data_source</item>
</item>
<item name="label" xsi:type="string" translate="true">General Information</item>
<item name="template" xsi:type="string">templates/form/collapsible</item>
</argument>
<settings>
<buttons>
<button name="save_and_continue" class="Aht\BannerSlider\Block\Adminhtml\Banner\Edit\SaveAndContinueButton"/>
<button name="save" class="Aht\BannerSlider\Block\Adminhtml\Banner\Edit\SaveButton"/>
<button name="reset" class="Aht\BannerSlider\Block\Adminhtml\Banner\Edit\ResetButton"/>
<button name="delete" class="Aht\BannerSlider\Block\Adminhtml\Banner\Edit\DeleteButton"/>
<button name="back" class="Aht\BannerSlider\Block\Adminhtml\Banner\Edit\BackButton"/>
</buttons>
<namespace>banner_form</namespace>
<dataScope>data</dataScope>
<deps>
<dep>banner_form.banner_form_data_source</dep>
</deps>
</settings>
<dataSource name="banner_form_data_source">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
<settings>
<submitUrl path="banner/manage/save"/>
</settings>
<dataProvider class="Aht\BannerSlider\Model\Banner\DataProvider" name="banner_form_data_source">
<settings>
<requestFieldName>id</requestFieldName>
<primaryFieldName>id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>
<fieldset name="general">
<settings>
<label/>
</settings>
<field name="id" formElement="input">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">banner</item>
</item>
</argument>
<settings>
<dataType>text</dataType>
<visible>false</visible>
<dataScope>id</dataScope>
</settings>
</field>
<field name="name" sortOrder="20" formElement="input">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">banner</item>
</item>
</argument>
<settings>
<validation>
<rule name="required-entry" xsi:type="boolean">true</rule>
</validation>
<dataType>text</dataType>
<label translate="true">Banner Name</label>
<dataScope>name</dataScope>
</settings>
</field>
</fieldset>
</form>
File: InstallSchema.php
class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
{
public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
if (!$installer->tableExists('banner')) {
$table = $installer->getConnection()->newTable(
$installer->getTable('banner')
)
->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
[
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
],
'ID'
)
->addColumn(
'name',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable => false'],
'Name'
)
->addColumn(
'created_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
'Created At'
)->addColumn(
'updated_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
'Updated At')
->setComment('Banner Table');
$installer->getConnection()->createTable($table);
}
if (!$installer->tableExists('slide')) {
$table = $installer->getConnection()->newTable(
$installer->getTable('slide')
)
->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
[
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
],
'ID'
)
->addColumn(
'banner_id',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
[],
'Banner Id'
)
->addColumn(
'name',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable => false'],
'Name'
)
->addColumn(
'url',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
[],
'URL'
)
->addColumn(
'image',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
[],
'Image'
)
->addColumn(
'created_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
'Created At'
)->addColumn(
'updated_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
'Updated At')
->setComment('Slide Table');
$installer->getConnection()->createTable($table);
}
$installer->endSetup();
}
}
File: UpgradeSchema.php
<?php
namespace Aht\BannerSlider\Setup;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
class UpgradeSchema implements UpgradeSchemaInterface
{
public function upgrade( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
$installer = $setup;
$installer->startSetup();
if(version_compare($context->getVersion(), '1.1.0', '<')) {
if (!$installer->tableExists('banner_slide')) {
$table = $installer->getConnection()->newTable(
$installer->getTable('banner_slide')
)
->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
[
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
],
'ID'
)
->addColumn(
'banner_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable => false'],
'Banner ID'
)
->addColumn(
'slide_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable => false'],
'Slide ID'
)
->addColumn(
'created_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
'Created At'
)->addColumn(
'updated_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
'Updated At')
->setComment('Banner Slide Table');
$installer->getConnection()->createTable($table);
}
if (!$installer->tableExists('banner_page')) {
$table = $installer->getConnection()->newTable(
$installer->getTable('banner_page')
)
->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
[
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
],
'ID'
)
->addColumn(
'banner_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable => false'],
'Banner ID'
)
->addColumn(
'page_url',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable => false'],
'Page Url'
)
->addColumn(
'created_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
'Created At'
)->addColumn(
'updated_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
'Updated At')
->setComment('Banner Page Table');
$installer->getConnection()->createTable($table);
}
if ($installer->tableExists('slide')){
$connection = $installer->getConnection();
$tableName = $installer->getTable('slide');
$columnName = 'banner_id';
if($connection->tableColumnExists($tableName,$columnName, $schemaName = null)){
$connection->dropColumn($tableName, $columnName, $schemaName = null);
}
}
}
$installer->endSetup();
}
}
EDIT 2 (fixed in EDIT 3):
I'm following Marius solution.
But it doesn't seem to work. It throw an error when i'm trying "php bin/magento setup:upgrade"
Installing schema... Upgrading schema... SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.banner_name' doesn't exist, query was: DESCRIBE BANNER_NAME
So here is what i update to UpdateSchema.php.
if ($installer->tableExists('banner')){
$connection = $installer->getConnection();
$connection->addIndex(
$setup->getIdxName(
$installer->getTable('banner'),
['name'],
AdapterInterface::INDEX_TYPE_FULLTEXT
),
['name'],
['type' => AdapterInterface::INDEX_TYPE_FULLTEXT]
);
}
EDIT 3:
So i was trying Marius solution like this (the difference is i give it a table in "addIndex" function):
if ($installer->tableExists('banner')){
$connection = $installer->getConnection();
$connection->addIndex(
$installer->getTable('banner'),
$setup->getIdxName(
$installer->getTable('banner'),
['name'],
AdapterInterface::INDEX_TYPE_FULLTEXT
),
['name'],
AdapterInterface::INDEX_TYPE_FULLTEXT
);
}
Also, before i do that, i have to clear cache and delete my module in "setup_module" table, and it work
. But for some reason, when i click "x" to clear the search, it throw 2 column exactly like the same( look the image below):
1 more problem is i cant search with "c". I've read some where that "fulltext_search" cant be use with 5 or less character. So there are any solution to fix this?
InstallSchema.php
file in here ?