| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?xml version="1.0" encoding="utf-8"?>
- <modification>
- <name>Reverb Integration</name>
- <code>reverb</code>
- <version>1.0.0</version>
- <author>Reverb OpenCart</author>
- <link>https://reverb.com/au/page/integrations</link>
- <!--
- ========================================================================
- FILE 1: admin/controller/catalog/product.php
- Inject Reverb data loading before the view is rendered,
- and Reverb data saving after addProduct / editProduct calls.
- ========================================================================
- -->
- <file path="admin/controller/catalog/product.php">
- <!--
- Load per-product Reverb data into $data[] so the Twig template
- can render the Reverb tab. Targets the final setOutput() call in
- the shared getForm() method, which is used by both add() and edit().
- -->
- <operation>
- <search><![CDATA[$this->response->setOutput($this->load->view('catalog/product', $data));]]></search>
- <add position="before"><![CDATA[
- // Reverb Integration: load per-product Reverb data
- $this->load->model('extension/module/reverb');
- $reverb_product_id = isset($this->request->get['product_id']) ? (int)$this->request->get['product_id'] : 0;
- $reverb_row = $this->model_extension_module_reverb->getProductMap($reverb_product_id);
- $data['reverb_sync_enabled'] = $reverb_row ? (int)$reverb_row['sync_enabled'] : 0;
- $data['reverb_condition_uuid'] = $reverb_row ? $reverb_row['condition_uuid'] : '';
- $data['reverb_category_uuid'] = $reverb_row ? $reverb_row['reverb_category_uuid'] : '';
- $data['reverb_listing_id'] = $reverb_row ? $reverb_row['reverb_listing_id'] : '';
- $data['reverb_conditions'] = $this->model_extension_module_reverb->getListingConditions();
- $data['reverb_oc_category_mappings'] = $this->model_extension_module_reverb->getCategoryMappings();
- $data['reverb_categories'] = $this->model_extension_module_reverb->getReverbCategories();
- ]]></add>
- </operation>
- <!--
- Save Reverb data after editProduct() is called.
- -->
- <operation>
- <search><![CDATA[$this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post);]]></search>
- <add position="after"><![CDATA[
- // Reverb Integration: save per-product Reverb data on edit
- if (isset($this->request->post['reverb_sync_enabled']) || isset($this->request->post['reverb_condition_uuid'])) {
- $this->load->model('extension/module/reverb');
- $this->model_extension_module_reverb->saveProductMap((int)$this->request->get['product_id'], [
- 'sync_enabled' => isset($this->request->post['reverb_sync_enabled']) ? 1 : 0,
- 'condition_uuid' => $this->request->post['reverb_condition_uuid'] ?? '',
- 'reverb_category_uuid' => $this->request->post['reverb_category_uuid'] ?? '',
- ]);
- }
- ]]></add>
- </operation>
- <!--
- Save Reverb data after addProduct() is called.
- -->
- <operation>
- <search><![CDATA[$product_id = $this->model_catalog_product->addProduct($this->request->post);]]></search>
- <add position="after"><![CDATA[
- // Reverb Integration: save per-product Reverb data on add
- if (isset($this->request->post['reverb_sync_enabled']) || isset($this->request->post['reverb_condition_uuid'])) {
- $this->load->model('extension/module/reverb');
- $this->model_extension_module_reverb->saveProductMap((int)$product_id, [
- 'sync_enabled' => isset($this->request->post['reverb_sync_enabled']) ? 1 : 0,
- 'condition_uuid' => $this->request->post['reverb_condition_uuid'] ?? '',
- 'reverb_category_uuid' => $this->request->post['reverb_category_uuid'] ?? '',
- ]);
- }
- ]]></add>
- </operation>
- </file>
- <!--
- ========================================================================
- FILE 2: admin/view/template/catalog/product.twig
- Add a "Reverb" tab to the product edit page.
- ========================================================================
- -->
- <file path="admin/view/template/catalog/product.twig">
- <!-- Add tab navigation item after the Design tab -->
- <operation>
- <search><![CDATA[<li><a href="#tab-design" data-toggle="tab">{{ tab_design }}</a></li>]]></search>
- <add position="after"><![CDATA[
- <li><a href="#tab-reverb" data-toggle="tab">Reverb</a></li>
- ]]></add>
- </operation>
- <!--
- Inject the Reverb tab pane. We include the dedicated template which
- has access to all $data variables (conditions, category mappings, etc.)
- loaded above by the PHP patch.
- -->
- <operation>
- <search><![CDATA[<div class="tab-pane" id="tab-design">]]></search>
- <add position="before"><![CDATA[
- {% include 'extension/module/reverb_product.twig' %}
- ]]></add>
- </operation>
- </file>
- </modification>
|