I tested all kinds of options and this is the best result without any bugs.
In hikashop.php, you forgot to add
protected $autoloadLanguage = true;
I changed the protected function handleOtherLanguages(&$item) and added an additional function to clean language - all, so it doesn't bug anymore. The code looks like this.
protected function handleOtherLanguages(&$item) {
$translationHelper = hikashop_get('helper.translation');
if ($translationHelper->isMulti()) {
$languages = $translationHelper->loadLanguages();
$mainColumns = array('title' => 'product_name', 'summary' => 'product_description', 'metakey' => 'product_keywords', 'metadesc' => 'product_meta_description', 'product_alias' => 'product_alias');
$fields = $this->params->get('fields');
if (!is_array($fields)) {
$fields = explode(',', (string)$fields);
}
if (!empty($fields) && count($fields)) {
$columns = array_merge($mainColumns, $fields);
}
else {
$columns = $mainColumns;
}
foreach ($languages as $language) {
if (method_exists($item, 'serialize')) {
$serialize = $item->serialize();
$class = $this->resultClass;
$copy = new $class();
@$copy->unserialize($serialize);
}
else {
$copy = hikashop_copy($item);
}
$copy->language = $language->code;
$copy->addTaxonomy('Language', $copy->language);
$copy->addTaxonomy('Type', 'Product');
if ($translationHelper->falang) {
$db = JFactory::getDBO();
$dbColumns = array();
foreach ($columns as $column) {
$dbColumns[] = $db->Quote($column);
}
$query = 'SELECT * FROM #__falang_content WHERE published=1 AND language_id = ' . (int)$language->id . ' AND reference_table=\'hikashop_product\' AND reference_id = ' . (int)$item->id . ' AND reference_field IN (' . implode(',', $dbColumns) . ')';
$db->setQuery($query);
$translations = $db->loadObjectList();
if (!empty($translations)) {
foreach ($translations as $t) {
if (empty($t->value)) continue;
$column = $t->reference_field;
$copy->$column = $t->value;
if (in_array($column, $mainColumns)) {
$key = array_search($column, $mainColumns);
if ($key == 'summary') {
$copy->summary = $this->prepareContent($copy->$column, $copy->params);
}
else {
$copy->$key = $copy->$column;
}
}
}
}
}
else {
$originals = array();
foreach ($columns as $column) {
if (!empty($item->$column)) {
$originals[$column] = $item->$column;
}
}
if (count($originals)) {
$translations = hikashop_translate($originals, $language->code);
foreach ($originals as $k => $o) {
if ($o == $translations[$k]) continue;
$copy->$k = $translations[$k];
foreach ($columns as $column) {
if (in_array($column, $mainColumns)) {
$key = array_search($column, $mainColumns);
if ($key == 'summary') {
$copy->summary = $this->prepareContent($copy->$column, $copy->params);
}
else {
$copy->$key = $copy->$column;
}
}
}
}
}
}
$copy->alias = '';
$this->addAlias($copy);
$extra = $this->_getElementMenuItem($copy);
$SEFlanguages = JLanguageHelper::getLanguages('sef');
foreach ($SEFlanguages as $sef => $lang) {
if ($lang->lang_code == $language->code) {
$extra .= '&lang=' . $sef;
break;
}
}
$copy->url = "index.php?option=com_hikashop&ctrl=product&task=show&cid=" . $copy->id . "&name=" . $copy->alias . $extra;
$copy->route = "index.php?option=com_hikashop&ctrl=product&task=show&cid=" . $copy->id . "&name=" . $copy->alias . $extra;
$this->indexer->index($copy);
$this->clearAllLanguage($item);
}
}
else {
return;
}
}
protected function clearAllLanguage(&$item) {
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$conditions = array($db->quoteName('language') . ' = ' . $db->quote('*'), $db->quoteName('type_id') . ' = ' . $item->type_id);
$query->delete($db->quoteName('#__finder_links'));
$query->where($conditions);
$db->setQuery($query);
$db->execute();
}
In the file hikashop j4.php in the protected function index(Joomla\Component\Finder\Administrator\Indexer\Result $item) at the top should be added
At the bottom, the code will remain
$this->indexer->index($item);
$this->handleOtherLanguages($item);
this is the end result