Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conlabz_CustomSourceIndex: Magento 1 Extension für EAV-Index mit Custom Source Model

Ein Magento 1 Modul, das Multiselect-Attribute mit einem Custom Source Model korrekt in den EAV-Index schreibt, damit Layered Navigation und Filter für diese Attribute funktionieren.

License: MIT Magento 1

🇩🇪 Deutsch · 🇬🇧 English

Inhaltsverzeichnis

Deutsch

Das Problem

Magento schreibt den EAV-Index für Multiselect-Attribute in Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source. Der Core-Code akzeptiert nur die Options-IDs, die in der Tabelle eav_attribute_option stehen.

Manche Multiselect-Attribute nutzen ein Custom Source Model. Diese Attribute erzeugen ihre Optionen im PHP-Code. Die Optionen stehen nicht in der Tabelle eav_attribute_option. Deshalb verwirft der Core-Code alle Werte dieser Attribute, und der Index bleibt leer. Layered Navigation und Filter funktionieren für diese Attribute nicht.

Die Lösung

Das Modul ersetzt die Core-Indexer-Resource durch Conlabz_CustomSourceIndex_Model_Rewrite_Catalog_Resource_Product_Indexer_Eav_Source.

Die neue Klasse macht drei Dinge:

  • Sie ruft getAllOptions() bei jedem Custom Source Model auf. Danach fügt sie diese Options-IDs der Liste der erlaubten Options-IDs hinzu. Siehe _getMultiSelectAttributeWithSourceModels().
  • Sie ignoriert Werte, die nicht numerisch sind. Eine Options-ID muss eine Ganzzahl sein.
  • Sie wählt die richtige Werte-Tabelle. Ab Magento 1.9.3.0 liest sie catalog_product_entity_text. Bei früheren Versionen liest sie catalog_product_entity_varchar.

Inhalt

Das Modul besteht aus zwei PHP-Klassen:

Datei Funktion
Helper/Data.php Ein leerer Helper. Er macht den Alias customsourceindex verfügbar.
Model/Rewrite/.../Eav/Source.php Der Indexer-Rewrite. Er enthält die gesamte Logik.

Das Modul legt keine Tabellen und keine Spalten an. Es hat keine Setup-Skripte, keine Admin-Einstellungen, keine Templates und keine Layout-Dateien.

Installation

Installation per Composer:

composer require conlabz/magex_customsourceindex

Alternativ per Modman:

modman clone git@github.com:conlabz/magex_customsourceindex.git

Danach diese Schritte durchführen:

  1. Magento-Cache leeren.
  2. Vollständigen Reindex des Product Attributes Index durchführen.

Einschränkungen

  • Der Rewrite ist eine Kopie einer protected Core-Methode. Er ist somit an die Magento-Version gebunden. Modul nach jedem Magento-Update testen.
  • Das Modul steht in Konflikt mit anderen Modulen, die catalog_resource/product_indexer_eav_source überschreiben.

Daten

  • Modulversion: 1.0.0
  • Code Pool: community
  • Abhängigkeit: Mage_Catalog

English

The Problem

Magento writes the EAV index for multiselect attributes in Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source. The core code accepts only the option IDs that are in the eav_attribute_option table.

Some multiselect attributes use a custom source model. These attributes make their options in PHP code. The options are not in the eav_attribute_option table. Thus the core code refuses all values of these attributes, and the index stays empty. Layered navigation and filters do not work for these attributes.

The Solution

The module replaces the core indexer resource with Conlabz_CustomSourceIndex_Model_Rewrite_Catalog_Resource_Product_Indexer_Eav_Source.

The new class does these three things:

  • It calls getAllOptions() on each custom source model. Then it adds these option IDs to the list of permitted option IDs. Refer to _getMultiSelectAttributeWithSourceModels().
  • It ignores values that are not numeric. An option ID must be an integer.
  • It selects the correct value table. For Magento 1.9.3.0 and later versions, it reads catalog_product_entity_text. For earlier versions, it reads catalog_product_entity_varchar.

Contents

The module has two PHP classes:

File Function
Helper/Data.php An empty helper. It makes the customsourceindex alias available.
Model/Rewrite/.../Eav/Source.php The indexer rewrite. It holds all of the logic.

The module makes no tables and no columns. It has no setup scripts, no admin settings, no templates and no layout files.

Installation

Install the module with composer:

composer require conlabz/magex_customsourceindex

You can also install the module with modman:

modman clone git@github.com:conlabz/magex_customsourceindex.git

Then do these steps:

  1. Clear the Magento cache.
  2. Do a full reindex of the Product Attributes index.

Limitations

  • The rewrite is a copy of a protected core method. Thus it is related to the Magento version. Test the module after each Magento update.
  • The module is in conflict with other modules that rewrite catalog_resource/product_indexer_eav_source.

Data

  • Module version: 1.0.0
  • Code pool: community
  • Dependency: Mage_Catalog

Lizenz

Diese Extension steht unter der MIT-Lizenz. Details siehe LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages