Conlabz_SCP ist eine Magento 1 Extension, die bei konfigurierbaren Produkten die Daten des ausgewählten Kind-Produkts statt der des Eltern-Produkts anzeigt.
Ein konfigurierbares Produkt zeigt normalerweise die Daten des Eltern-Produkts an. Dieses Modul zeigt stattdessen die Daten des ausgewählten Kind-Produkts an.
Das Modul macht Folgendes:
- Es ersetzt das Preismodell von konfigurierbaren Produkten. Der Preis kommt vom ausgewählten einfachen Produkt.
- Es sendet die ausgewählten Optionen an einen Controller. Der Controller lädt das Kind-Produkt und liefert das HTML der konfigurierten Blöcke.
- Es ersetzt das HTML dieser Blöcke auf der Seite. Die Seite wird dabei nicht neu geladen.
- Es speichert das Ergebnis jeder Optionskombination in einem Cache im Browser.
| Datei | Funktion |
|---|---|
Helper/Data.php |
Liest die Konfiguration und baut die AJAX-URL. |
Model/Observer.php |
Fügt die AJAX-URL zur JSON-Konfiguration hinzu. Umschließt jeden konfigurierten Block mit einem data-conscp-block Wrapper. |
Model/Catalog/Product/Type/Configurable/Price.php |
Verwendet den finalen Preis des einfachen Produkts. |
controllers/ProductController.php |
Action conscp/product/simple. Liefert das Block-HTML als JSON. |
js/conscp/scp.js |
Fügt reloadBlocks, replaceBlocks und die Loader-Funktionen zu Product.Config hinzu. |
template/conscp/catalog/product/view/init.phtml |
Verbindet das JavaScript mit den Options-Auswahlfeldern. |
Installiere das Modul mit modman oder mit Composer.
modman clone git@github.com:conlabz/magex_scp.git
composer require conlabz/magex_scp
Leere danach den Magento-Cache.
Gehe zu System > Configuration > Catalog > ConSCP > General.
Das Feld Simple configurable blocks enthält die Layout-Namen der Blöcke, die aktualisiert werden sollen. Schreibe einen Block-Namen pro Zeile.
Standardwert:
product.attributes
product.description
Das Modul sendet das Event conscp_response_simple_data bevor es die JSON-Antwort sendet. Nutze dieses Event, um weitere Daten zur Antwort hinzuzufügen.
- Die Blöcke müssen im Layout-Handle
catalog_product_viewliegen. Der Controller nutzt diesen Handle zusammen mitPRODUCT_TYPE_simple. - Das Modul nutzt die Prototype-JavaScript-Bibliothek. Das ist die Standardbibliothek von Magento 1.
A configurable product normally shows the data of the parent product. This module shows the data of the selected child product instead.
The module does these things:
- It replaces the price model of configurable products. The price comes from the selected simple product.
- It sends the selected options to a controller. The controller loads the child product and gives the HTML of the configured blocks.
- It replaces the HTML of these blocks in the page. The page does not reload.
- It keeps the result of each option set in a cache in the browser.
| File | Function |
|---|---|
Helper/Data.php |
Reads the configuration and builds the AJAX URL. |
Model/Observer.php |
Adds the AJAX URL to the JSON config. Puts a data-conscp-block wrapper around each configured block. |
Model/Catalog/Product/Type/Configurable/Price.php |
Uses the final price of the simple product. |
controllers/ProductController.php |
Action conscp/product/simple. Gives the block HTML as JSON. |
js/conscp/scp.js |
Adds reloadBlocks, replaceBlocks and the loader functions to Product.Config. |
template/conscp/catalog/product/view/init.phtml |
Connects the JavaScript to the option select boxes. |
Install the module with modman or with Composer.
modman clone git@github.com:conlabz/magex_scp.git
composer require conlabz/magex_scp
Then clear the Magento cache.
Go to System > Configuration > Catalog > ConSCP > General.
The field Simple configurable blocks contains the layout names of the blocks to refresh. Write one block name in each line.
Default value:
product.attributes
product.description
The module sends the event conscp_response_simple_data before it sends the JSON response. Use this event to add more data to the response.
- The blocks must be in the
catalog_product_viewlayout handle. The controller uses this handle together withPRODUCT_TYPE_simple. - The module uses the Prototype JavaScript library. This is the standard library of Magento 1.
Diese Extension steht unter der MIT-Lizenz. Details siehe LICENSE.