install.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <modification>
  3. <name>Reverb Integration</name>
  4. <code>reverb</code>
  5. <version>1.0.2</version>
  6. <author>Reverb OpenCart</author>
  7. <link>https://reverb.com/au/page/integrations</link>
  8. <!--
  9. ========================================================================
  10. FILE 1: admin/controller/catalog/product.php
  11. Inject Reverb data loading before the view is rendered,
  12. and Reverb data saving after addProduct / editProduct calls.
  13. ========================================================================
  14. -->
  15. <file path="admin/controller/catalog/product.php">
  16. <operation>
  17. <search><![CDATA[$this->response->setOutput($this->load->view('catalog/product', $data));]]></search>
  18. <add position="before"><![CDATA[
  19. $this->load->model('extension/module/reverb');
  20. $reverb_product_id = isset($this->request->get['product_id']) ? (int)$this->request->get['product_id'] : 0;
  21. $reverb_row = $this->model_extension_module_reverb->getProductMap($reverb_product_id);
  22. $data['reverb_sync_enabled'] = $reverb_row ? (int)$reverb_row['sync_enabled'] : 0;
  23. $data['reverb_condition_uuid'] = $reverb_row ? $reverb_row['condition_uuid'] : '';
  24. $data['reverb_category_uuid'] = $reverb_row ? $reverb_row['reverb_category_uuid'] : '';
  25. $data['reverb_listing_id'] = $reverb_row ? $reverb_row['reverb_listing_id'] : '';
  26. $data['reverb_conditions'] = $this->model_extension_module_reverb->getListingConditions();
  27. $data['reverb_categories'] = $this->model_extension_module_reverb->getReverbCategories();
  28. ]]></add>
  29. </operation>
  30. <operation>
  31. <search><![CDATA[$this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post);]]></search>
  32. <add position="after"><![CDATA[
  33. if (isset($this->request->post['reverb_sync_enabled']) || isset($this->request->post['reverb_condition_uuid'])) {
  34. $this->load->model('extension/module/reverb');
  35. $this->model_extension_module_reverb->saveProductMap((int)$this->request->get['product_id'], array(
  36. 'sync_enabled' => isset($this->request->post['reverb_sync_enabled']) ? 1 : 0,
  37. 'condition_uuid' => isset($this->request->post['reverb_condition_uuid']) ? $this->request->post['reverb_condition_uuid'] : '',
  38. 'reverb_category_uuid' => isset($this->request->post['reverb_category_uuid']) ? $this->request->post['reverb_category_uuid'] : '',
  39. ));
  40. }
  41. ]]></add>
  42. </operation>
  43. <operation>
  44. <search><![CDATA[$product_id = $this->model_catalog_product->addProduct($this->request->post);]]></search>
  45. <add position="after"><![CDATA[
  46. if (isset($this->request->post['reverb_sync_enabled']) || isset($this->request->post['reverb_condition_uuid'])) {
  47. $this->load->model('extension/module/reverb');
  48. $this->model_extension_module_reverb->saveProductMap((int)$product_id, array(
  49. 'sync_enabled' => isset($this->request->post['reverb_sync_enabled']) ? 1 : 0,
  50. 'condition_uuid' => isset($this->request->post['reverb_condition_uuid']) ? $this->request->post['reverb_condition_uuid'] : '',
  51. 'reverb_category_uuid' => isset($this->request->post['reverb_category_uuid']) ? $this->request->post['reverb_category_uuid'] : '',
  52. ));
  53. }
  54. ]]></add>
  55. </operation>
  56. </file>
  57. <!--
  58. ========================================================================
  59. FILE 2: admin/view/template/catalog/product.twig
  60. Add a "Reverb" tab to the product edit page.
  61. Anchored on the SEO tab (always present in OC3) rather than Design tab
  62. to avoid mismatches with customised themes. Content embedded inline to
  63. avoid Twig include path resolution issues.
  64. ========================================================================
  65. -->
  66. <file path="admin/view/template/catalog/product.twig">
  67. <operation>
  68. <search><![CDATA[<li><a href="#tab-seo" data-toggle="tab">{{ tab_seo }}</a></li>]]></search>
  69. <add position="after"><![CDATA[<li><a href="#tab-reverb" data-toggle="tab">Reverb</a></li>]]></add>
  70. </operation>
  71. <operation>
  72. <search><![CDATA[<div class="tab-pane" id="tab-seo">]]></search>
  73. <add position="before"><![CDATA[
  74. <div class="tab-pane" id="tab-reverb">
  75. <div class="panel panel-default" style="margin-top:15px;">
  76. <div class="panel-body">
  77. <div class="form-group">
  78. <label class="col-sm-2 control-label">List on Reverb</label>
  79. <div class="col-sm-10">
  80. <input type="hidden" name="reverb_sync_enabled" value="0" />
  81. <label class="checkbox-inline">
  82. <input type="checkbox" name="reverb_sync_enabled" value="1"
  83. {% if reverb_sync_enabled %}checked="checked"{% endif %} />
  84. Enable sync for this product
  85. </label>
  86. <p class="help-block">Enable to include this product in Reverb syncs. The product must also be in an allowed category (set in the Reverb module settings).</p>
  87. </div>
  88. </div>
  89. <div class="form-group">
  90. <label class="col-sm-2 control-label">Condition</label>
  91. <div class="col-sm-4">
  92. <select name="reverb_condition_uuid" class="form-control">
  93. <option value="">-- Select Condition --</option>
  94. {% for condition in reverb_conditions %}
  95. <option value="{{ condition.uuid }}"
  96. {% if reverb_condition_uuid == condition.uuid %}selected="selected"{% endif %}>
  97. {{ condition.display_name }}
  98. </option>
  99. {% endfor %}
  100. </select>
  101. <p class="help-block">Required by Reverb. Describes the physical state of the item.</p>
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <label class="col-sm-2 control-label">Reverb Category</label>
  106. <div class="col-sm-6">
  107. <select name="reverb_category_uuid" class="form-control">
  108. <option value="">-- Use category mapping default --</option>
  109. {% for rc in reverb_categories %}
  110. <option value="{{ rc.uuid }}"
  111. {% if reverb_category_uuid == rc.uuid %}selected="selected"{% endif %}>
  112. {{ rc.full_name|default(rc.name) }}
  113. </option>
  114. {% endfor %}
  115. </select>
  116. <p class="help-block">Leave blank to use the default mapping from the Reverb module settings.</p>
  117. </div>
  118. </div>
  119. {% if reverb_listing_id %}
  120. <div class="form-group">
  121. <label class="col-sm-2 control-label">Reverb Listing</label>
  122. <div class="col-sm-10">
  123. <p class="form-control-static">
  124. <a href="https://reverb.com/item/{{ reverb_listing_id }}" target="_blank" rel="noopener">
  125. <i class="fa fa-external-link"></i> View on Reverb (ID: {{ reverb_listing_id }})
  126. </a>
  127. </p>
  128. </div>
  129. </div>
  130. {% else %}
  131. <div class="form-group">
  132. <label class="col-sm-2 control-label">Reverb Listing</label>
  133. <div class="col-sm-10">
  134. <p class="form-control-static text-muted">Not yet synced to Reverb.</p>
  135. </div>
  136. </div>
  137. {% endif %}
  138. </div>
  139. </div>
  140. </div>
  141. ]]></add>
  142. </operation>
  143. </file>
  144. </modification>