workarea-browse_option 2.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +14 -0
  7. data/CHANGELOG.md +315 -0
  8. data/CODE_OF_CONDUCT.md +3 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Gemfile +12 -0
  11. data/LICENSE +52 -0
  12. data/README.md +67 -0
  13. data/Rakefile +52 -0
  14. data/app/controllers/workarea/admin/categorizations_controller.decorator +25 -0
  15. data/app/controllers/workarea/admin/featured_products_controller.decorator +63 -0
  16. data/app/models/workarea/catalog/product.decorator +20 -0
  17. data/app/models/workarea/featured_browse_option_products.rb +13 -0
  18. data/app/models/workarea/search/storefront/product_option.rb +51 -0
  19. data/app/models/workarea/search/storefront/product_option_image_url.rb +18 -0
  20. data/app/queries/workarea/categorization.decorator +12 -0
  21. data/app/queries/workarea/search/product_entries.decorator +17 -0
  22. data/app/queries/workarea/search/related_products.decorator +30 -0
  23. data/app/services/workarea/browse_option_ids.rb +39 -0
  24. data/app/view_models/workarea/admin/bulk_action_product_edit_view_model.decorator +10 -0
  25. data/app/view_models/workarea/admin/featured_browse_option_product_view_model.rb +18 -0
  26. data/app/view_models/workarea/admin/featured_browse_option_products_view_model.rb +23 -0
  27. data/app/view_models/workarea/admin/featured_products_search_view_model.rb +45 -0
  28. data/app/view_models/workarea/admin/product_view_model.decorator +9 -0
  29. data/app/view_models/workarea/storefront/product_view_model/cache_key.decorator +12 -0
  30. data/app/view_models/workarea/storefront/product_view_model/image_collection.decorator +26 -0
  31. data/app/view_models/workarea/storefront/product_view_model.decorator +15 -0
  32. data/app/views/workarea/admin/bulk_action_product_edits/_browse_option_field.html.haml +10 -0
  33. data/app/views/workarea/admin/catalog_products/_browse_option_attribute_card.html.haml +3 -0
  34. data/app/views/workarea/admin/catalog_products/_browse_option_field.html.haml +3 -0
  35. data/app/views/workarea/api/storefront/products/_browse_option_field.json.jbuilder +2 -0
  36. data/app/workers/workarea/bulk_index_products.decorator +34 -0
  37. data/app/workers/workarea/index_category_changes.decorator +7 -0
  38. data/app/workers/workarea/index_product.decorator +18 -0
  39. data/bin/rails +17 -0
  40. data/config/initializers/appends.rb +21 -0
  41. data/config/initializers/configuration.rb +17 -0
  42. data/config/locales/en.yml +8 -0
  43. data/lib/tasks/browse_option_tasks.rake +4 -0
  44. data/lib/workarea/browse_option/engine.rb +20 -0
  45. data/lib/workarea/browse_option/version.rb +5 -0
  46. data/lib/workarea/browse_option.rb +11 -0
  47. data/test/dummy/Rakefile +6 -0
  48. data/test/dummy/app/assets/config/manifest.js +4 -0
  49. data/test/dummy/app/assets/images/.keep +0 -0
  50. data/test/dummy/app/assets/javascripts/application.js +13 -0
  51. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  52. data/test/dummy/app/controllers/application_controller.rb +3 -0
  53. data/test/dummy/app/controllers/concerns/.keep +0 -0
  54. data/test/dummy/app/helpers/application_helper.rb +2 -0
  55. data/test/dummy/app/jobs/application_job.rb +2 -0
  56. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  57. data/test/dummy/app/models/concerns/.keep +0 -0
  58. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  59. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  60. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  61. data/test/dummy/bin/bundle +3 -0
  62. data/test/dummy/bin/rails +4 -0
  63. data/test/dummy/bin/rake +4 -0
  64. data/test/dummy/bin/setup +34 -0
  65. data/test/dummy/bin/update +29 -0
  66. data/test/dummy/config/application.rb +20 -0
  67. data/test/dummy/config/boot.rb +5 -0
  68. data/test/dummy/config/cable.yml +9 -0
  69. data/test/dummy/config/environment.rb +5 -0
  70. data/test/dummy/config/environments/development.rb +57 -0
  71. data/test/dummy/config/environments/production.rb +86 -0
  72. data/test/dummy/config/environments/test.rb +43 -0
  73. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  74. data/test/dummy/config/initializers/assets.rb +11 -0
  75. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  76. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  77. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/test/dummy/config/initializers/inflections.rb +16 -0
  79. data/test/dummy/config/initializers/mime_types.rb +4 -0
  80. data/test/dummy/config/initializers/new_framework_defaults.rb +18 -0
  81. data/test/dummy/config/initializers/session_store.rb +3 -0
  82. data/test/dummy/config/initializers/workarea.rb +5 -0
  83. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  84. data/test/dummy/config/locales/en.yml +23 -0
  85. data/test/dummy/config/puma.rb +47 -0
  86. data/test/dummy/config/routes.rb +6 -0
  87. data/test/dummy/config/secrets.yml +22 -0
  88. data/test/dummy/config/spring.rb +6 -0
  89. data/test/dummy/config.ru +5 -0
  90. data/test/dummy/db/seeds.rb +10 -0
  91. data/test/dummy/lib/assets/.keep +0 -0
  92. data/test/dummy/log/.keep +0 -0
  93. data/test/dummy/public/404.html +67 -0
  94. data/test/dummy/public/422.html +67 -0
  95. data/test/dummy/public/500.html +66 -0
  96. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  97. data/test/dummy/public/apple-touch-icon.png +0 -0
  98. data/test/dummy/public/favicon.ico +1 -0
  99. data/test/fixtures/files/large.jpg +0 -0
  100. data/test/fixtures/files/medium.jpg +0 -0
  101. data/test/integration/workarea/admin/browse_option_categorizations_integration_test.rb +47 -0
  102. data/test/integration/workarea/admin/browse_option_featured_products_integration_test.rb +45 -0
  103. data/test/integration/workarea/api/storefront/browse_option_product_integration_test.rb +74 -0
  104. data/test/models/workarea/catalog/browse_option_product_test.rb +20 -0
  105. data/test/models/workarea/featured_browse_option_products_test.rb +28 -0
  106. data/test/models/workarea/search/storefront/product_option_image_url_test.rb +19 -0
  107. data/test/models/workarea/search/storefront/product_option_test.rb +105 -0
  108. data/test/queries/workarea/browse_option_categorization_test.rb +20 -0
  109. data/test/queries/workarea/search/product_entries_test.decorator +19 -0
  110. data/test/queries/workarea/search/related_products_test.decorator +39 -0
  111. data/test/services/workarea/browse_option_ids_test.rb +63 -0
  112. data/test/system/workarea/admin/browse_option_featured_products_system_test.rb +57 -0
  113. data/test/system/workarea/admin/bulk_action_product_edit_browse_option_test.rb +54 -0
  114. data/test/system/workarea/storefront/browse_option_system_test.rb +110 -0
  115. data/test/test_helper.rb +10 -0
  116. data/test/view_models/workarea/admin/browse_option_product_view_model_test.rb +22 -0
  117. data/test/view_models/workarea/storefront/browse_option_product_view_model_test.rb +74 -0
  118. data/test/view_models/workarea/storefront/product_view_model/image_collection_test.rb +74 -0
  119. data/test/workers/workarea/browse_option_index_product_test.rb +37 -0
  120. data/test/workers/workarea/bulk_index_products_test.decorator +49 -0
  121. data/workarea-browse_option.gemspec +21 -0
  122. metadata +184 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 36962f203f973f8b170772166b3d044e8208430a9d1e64bc188251dcd54e6a14
4
+ data.tar.gz: 71bdd4b75a37c88c7ce5ab2ff212edce7a2890d4b70a22122755153326676146
5
+ SHA512:
6
+ metadata.gz: 9f2655f7fd7dbde853e5cccecb59f4d1ac724a5cbad3d8162769c7a9aaa240bd1bf1b208cd136690aadadb9e467935194b54226040cfcab119fb6af88a4a1025
7
+ data.tar.gz: 15c6587978dd8b514ac0dc869892363d64c3fc9a18ba74b74ba870292643949475400e358cc1e76322c05d49d21ffe1d81de397755a92066b261b85dceb4150f
data/.editorconfig ADDED
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.decorator,*.yml,*.yaml,*.jbuilder}]
12
+ indent_size = 2
13
+ indent_style = space
14
+
15
+ [{*.js,*.jst,*.ejs,*.scss}]
16
+ indent_size = 4
17
+
18
+ [*.md]
19
+ indent_size = 4
20
+ trim_trailing_whitespace = false
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve Workarea
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ⚠️**Before you create**⚠️
11
+ Please verify the issue you're experiencing is not part of your Workarea project customizations. The best way to do this is with a [vanilla Workarea installation](https://developer.workarea.com/articles/create-a-new-host-application.html). This will help us spend time on fixes/improvements for the whole community. Thank you!
12
+
13
+ **Describe the bug**
14
+ A clear and concise description of what the bug is.
15
+
16
+ **To Reproduce**
17
+ Steps to reproduce the behavior:
18
+ 1. Go to '...'
19
+ 2. Click on '....'
20
+ 3. Scroll down to '....'
21
+ 4. See error
22
+
23
+ **Expected behavior**
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Workarea Setup (please complete the following information):**
27
+ - Workarea Version: [e.g. v3.4.6]
28
+ - Plugins [e.g. workarea-blog, workarea-sitemaps]
29
+
30
+ **Attachments**
31
+ If applicable, add any attachments to help explain your problem, things like:
32
+ - screenshots
33
+ - Gemfile.lock
34
+ - test cases
35
+
36
+ **Additional context**
37
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Documentation request
3
+ about: Suggest documentation
4
+ title: ''
5
+ labels: documentation
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your documentation related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm confused by [...]
12
+
13
+ **Describe the article you'd like**
14
+ A clear and concise description of what would be in the documentation article.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for Workarea
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ Gemfile.lock
9
+ test/dummy/public/system/
10
+ .DS_STORE
11
+ node_modules
12
+ test/reports
13
+ package.json
14
+ yarn.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,315 @@
1
+ Workarea Browse Option 2.1.6 (2019-08-21)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Open Source!
5
+
6
+
7
+
8
+ Workarea Browse Option 2.1.5 (2019-08-06)
9
+ --------------------------------------------------------------------------------
10
+
11
+ * Omit Optionless Images From Primary Image Lookup
12
+
13
+ When looking up a primary image based on the browse option, omit any
14
+ images that have no option set. This prevents an error where
15
+ `.optionize` gets called on a `nil` object.
16
+
17
+ Discovered by **Ryan Tulino** of Syatt. Thanks Ryan!
18
+
19
+ WLBBOPTION-33
20
+ Tom Scott
21
+
22
+
23
+
24
+ Workarea Browse Option 2.1.4 (2019-07-23)
25
+ --------------------------------------------------------------------------------
26
+
27
+ * Fix Inconsistency When Products Are Packaged
28
+
29
+ Products that browse by option can be packaged into `package` or
30
+ `family` products, which query for a set of product IDs. These are not
31
+ necessarily the same IDs that you would get out of MongoDB, in the
32
+ browse-by-option world, they include the option for which you are
33
+ indexing in search. Because of this, browse option products which are
34
+ part of a larger package product are not visible in some areas of the
35
+ storefront and admin. This has now been fixed by redefining the
36
+ `#packaged_products` method to query for the base ID of each product in
37
+ Mongo, and then fill in the correct option based on the product's
38
+ `browse_option` value. While this won't enforce that option in the
39
+ package or family product, it will pre-select the option on the
40
+ storefront so that it will display properly and consistently with what
41
+ the admin picked out when creating the product.
42
+
43
+ WLBBOPTION-30
44
+ Tom Scott
45
+
46
+ * Bulk Delete Product Options Before Reindexing
47
+
48
+ Revert to the bulk action instead of using delete_by_query to avert
49
+ performance problems when used on a large scale.
50
+
51
+ WLBBOPTION-32
52
+ Tom Scott
53
+
54
+ * Fix Faceting of Product Options
55
+
56
+ When browse-by-option products are indexed, a lot of data was previously
57
+ lost due to the way each variant details hash was merged with another.
58
+ The arrays that make up each detail did not concatenate the way one might
59
+ expect when merging hashes together, so the `#variant_facets` method has
60
+ been updated to iterate over each variant's details hash and safely
61
+ combine all fields into an Array of values. This successfully groups
62
+ together the facets for a particular browse-option, so for example, a
63
+ product with multiple sizes assigned to the same color will have all of
64
+ those sizes indexed as facet values in search.
65
+
66
+ WLBBOPTION-29
67
+ Tom Scott
68
+
69
+ * Use latest released Workarea version
70
+
71
+ Tom Scott
72
+
73
+
74
+
75
+ Workarea Browse Option 2.1.3 (2019-05-28)
76
+ --------------------------------------------------------------------------------
77
+
78
+ * Use Browse Option IDs in Categorizations
79
+
80
+ When browse option products are manually categorized from the product
81
+ page, it is assumed that all options of the product should be featured
82
+ in the category. Workarea now decorates the
83
+ `Admin::CategorizationsController` to iterate over all browse option IDs
84
+ and add them to the category's featured products instead of the ID of
85
+ the main product, which may not actually exist in the index.
86
+
87
+ WLBBOPTION-24
88
+ Tom Scott
89
+
90
+ * Fix Removing Featured Browse Option Products
91
+
92
+ Featured Browse Option Products appeared to not remove properly because
93
+ their response was rendering back the first option rather than the one
94
+ that was selected. As a result, the products stayed in featured product
95
+ IDs, but we still showed a message indicating they had been removed.
96
+ The view model used to render the product back once it's been
97
+ added/removed from featured products has been changed to
98
+ `Admin::FeaturedBrowseOptionProductViewModel`, and the controller passes
99
+ in the current product's browse option if it is configured to browse by
100
+ option.
101
+
102
+ WLBBOPTION-24
103
+ Tom Scott
104
+
105
+
106
+
107
+ Workarea Browse Option 2.1.2 (2019-04-02)
108
+ --------------------------------------------------------------------------------
109
+
110
+ * Handle indexing changes to categories with browse option product ids
111
+
112
+ WLBBOPTION-28
113
+ Matt Duffy
114
+
115
+ * Update for workarea v3.4 compatibility
116
+
117
+ WLBBOPTION-27
118
+ Matt Duffy
119
+
120
+
121
+
122
+ Workarea Browse Option 2.1.1 (2019-01-22)
123
+ --------------------------------------------------------------------------------
124
+
125
+ * Improve readme
126
+
127
+ WLBBOPTION-26
128
+ ECOMMERCE-6523
129
+ Chris Cressman
130
+
131
+
132
+
133
+ Workarea Browse Option 2.1.0 (2018-10-16)
134
+ --------------------------------------------------------------------------------
135
+
136
+ * Allow each occurance of browse option product to be featured separately
137
+
138
+ WLBBOPTION-23
139
+ Matt Duffy
140
+
141
+
142
+
143
+ Workarea Browse Option 2.0.0 (2018-05-24)
144
+ --------------------------------------------------------------------------------
145
+
146
+ * Update tests to work with bulk action changes
147
+
148
+ WLBBOPTION-21
149
+ Matt Duffy
150
+
151
+ * Leverage Workarea Changelog task
152
+
153
+ ECOMMERCE-5355
154
+ Curt Howard
155
+
156
+ * Fix search results upper limit when bulk-indexing
157
+
158
+ When bulk-indexing products, set the `:size` option to the total amount
159
+ of entries in the index, not to the total amount of products. This is
160
+ because browse_option products typically have an entry per variant, and
161
+ thus there are more results than allowed back using the Elasticsearch
162
+ query. We're now finding the total amount of entries in the index for
163
+ these products and setting the `:size` param to that instead.
164
+
165
+ WLBBOPTION-20
166
+ Tom Scott
167
+
168
+ * Account for SKUs with spaces in them
169
+
170
+ When SKUs have spaces in them, some of our queries that split lists of
171
+ product IDs on a space character (for deleting and reindexing each
172
+ browse-option for a single parent product) don't behave very well.
173
+ Instead of making a bare query with each ID separated by a space, run a
174
+ `terms` query for the collection of `catalog_ids` as an Array. This
175
+ ensures that each `catalog_id` is treated in isolation.
176
+
177
+ WLBBOPTION-19
178
+ Tom Scott
179
+
180
+ * Correct recommended product IDs
181
+
182
+ Product IDs coming through for recommendations were not correct, because
183
+ they were using the base product ID without each variant's browse option
184
+ value, due to the wrong search model being used in the
185
+ `Search::RelatedProducts` query. Map over all products as well as their
186
+ options using the `ProductOption` search model if the product is browsed
187
+ by option.
188
+
189
+ WLBBOPTION-18
190
+ Tom Scott
191
+
192
+ * Fixes for headless Chrome
193
+
194
+ Ben Crouse
195
+
196
+
197
+
198
+ Workarea Browse by Option 1.2.5 (2018-02-20)
199
+ --------------------------------------------------------------------------------
200
+
201
+ * Find image for browse option products in search
202
+
203
+ The search model for browse-by-option products didn't include an
204
+ override for `#primary_image` that finds the correct image by its
205
+ option. If an image cannot be found, the product's original
206
+ `primary_image` is used as a default.
207
+
208
+ WLBBOPTION-10
209
+ Tom Scott
210
+
211
+
212
+ Workarea Browse by Option 1.2.4 (2018-01-09)
213
+ --------------------------------------------------------------------------------
214
+
215
+ * Rework id escaping for product indexing for compatibility with workarea v3.2
216
+
217
+ WLBBOPTION-17
218
+ Matt Duffy
219
+
220
+
221
+ Workarea Browse by Option 1.2.3 (2017-11-14)
222
+ --------------------------------------------------------------------------------
223
+
224
+ * Add regex to escape irregular product ids during reindexing
225
+
226
+ WLBBOPTION-15
227
+ Matt Duffy
228
+
229
+ * Add regex to escape irregular product ids during reindexing
230
+
231
+ WLBBOPTION-15
232
+ Matt Duffy
233
+
234
+
235
+ Workarea Browse by Option 1.2.2 (2017-10-31)
236
+ --------------------------------------------------------------------------------
237
+
238
+ * Move configuration into initializers
239
+
240
+ WLBBOPTION-16
241
+ Matt Duffy
242
+
243
+
244
+ Workarea Browse by Option 1.2.1 (2017-09-26)
245
+ --------------------------------------------------------------------------------
246
+
247
+ * Don't show browse by option product if all variants are inactive
248
+
249
+ WLBBOPTION-12
250
+ Brian Berg
251
+
252
+
253
+ Workarea Browse by Option 1.2.0 (2017-09-22)
254
+ --------------------------------------------------------------------------------
255
+
256
+ * Update for compatibility with workarea v3.1
257
+
258
+ WLBBOPTION-11
259
+ Matt Duffy
260
+
261
+
262
+ Workarea Browse by Option 1.1.2 (2017-09-26)
263
+ --------------------------------------------------------------------------------
264
+
265
+ * Don't show browse by option product if all variants are inactive
266
+
267
+ WLBBOPTION-12
268
+ Brian Berg
269
+
270
+
271
+ Workarea Browse by Option 1.1.1 (2017-09-22)
272
+ --------------------------------------------------------------------------------
273
+
274
+ * Fix workarea dependency to < 3.1.0
275
+
276
+ WLBBOPTION-13
277
+ Curt Howard
278
+
279
+
280
+ Workarea Browse by Option 1.1.0 (2017-09-15)
281
+ --------------------------------------------------------------------------------
282
+
283
+ * Handle products that do not have browse option set
284
+
285
+ WLBBOPTION-9
286
+ Matt Duffy
287
+
288
+ * Add partial to render browse option field for storefront api products
289
+
290
+ WLBBOPTION-9
291
+ Matt Duffy
292
+
293
+
294
+ Workarea Browse by Option 1.0.0 (2017-05-17)
295
+ --------------------------------------------------------------------------------
296
+
297
+ * Ensure selecting no browse option on product bulk editing clears the field
298
+
299
+ WLBBOPTION-7
300
+ Matt Duffy
301
+
302
+ * Fix param value of browse option for bulk action product edit, add test
303
+
304
+ WLBBOPTION-7
305
+ Matt Duffy
306
+
307
+ * Fix issues with bulk editing browse options
308
+
309
+ WLBBOPTION-7
310
+ Matt Duffy
311
+
312
+ * Update for compatibility with workarea 3
313
+
314
+ WLBBOPTION-5
315
+ Matt Duffy
@@ -0,0 +1,3 @@
1
+ View this plugin's code of conduct here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CODE_OF_CONDUCT.md>
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's contribution guidelines here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CONTRIBUTING.md>
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "git@github.com:#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in browse_option.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ gem 'bundler-audit'
10
+ gem 'listen'
11
+
12
+ gem 'workarea-api', '>= 4.x'
data/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ Workarea Browse Option
2
+ ================================================================================
3
+
4
+ A Workarea Commerce plugin that enables the display of products by their various options (e.g. color) when browsing them in the Storefront.
5
+
6
+
7
+ Overview
8
+ --------------------------------------------------------------------------------
9
+
10
+ * Allows each product to be "broken out" into multiple representations when browsing in the Storefront, based on a particular product option, such as color
11
+ * Allows admins to choose which products "browse by option" and to choose the specific option for each product
12
+ * Allows admins to choose a particular representation of the product (e.g. the blue one) when featuring it within a category or search results
13
+ * Prevents representations of the same product from appearing in collections of related products (e.g. upsells)
14
+
15
+ Getting Started
16
+ --------------------------------------------------------------------------------
17
+
18
+ Add the gem to your application's Gemfile:
19
+
20
+ ```ruby
21
+ # ...
22
+ gem 'workarea-browse_option'
23
+ # ...
24
+ ```
25
+
26
+ Update your application's bundle.
27
+
28
+ ```bash
29
+ cd path/to/application
30
+ bundle
31
+ ```
32
+
33
+ Features
34
+ --------------------------------------------------------------------------------
35
+
36
+
37
+ ### Administration of Browse Options
38
+
39
+ * When editing a product in the Admin (or bulk editing many), an administrator can choose a "browses by" option for that product
40
+ * The UI for choosing this option is a select menu, which is populated with the keys of the details for all of the product's variants
41
+ * When a value is selected for the browse option, the product is said to "browse by option" and is represented differently in Elasticsearch (see below)
42
+ * Each product's attributes card in the Admin displays its browse option (if any)
43
+
44
+
45
+ ### Search Indexing & Browsing
46
+
47
+ * Products that browse by option are stored as multiple documents (one per value of the selected option) within each Storefront search index
48
+ * Each option-specific search document is built from only those variants of the product that match the particular option value (e.g. blue for color)
49
+ * When browsing (e.g. search results and category listings), such products potentially appear in results multiple times (up to once per search document in that index)
50
+ * Each representation of a product uses a relevant product image (if available), such as a blue image for the blue representation of the product
51
+ * Clicking through any of the product's browse results takes the customer to the same product details (from Mongo)
52
+
53
+
54
+ ### State/Caching in the Storefront
55
+
56
+ * If a product browses by option, the particular option value is persisted through the `:option` param when clicking through to the product's details
57
+ * When a product browses by option and the `:option` param is set, the specific option value is used in the product's cache key, affecting show, summary, and pricing view caches
58
+
59
+ Workarea Commerce Documentation
60
+ --------------------------------------------------------------------------------
61
+
62
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation.
63
+
64
+ License
65
+ --------------------------------------------------------------------------------
66
+
67
+ Workarea Browse Option is released under the [Business Software License](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'rdoc/task'
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'Tasker'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.md')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
19
+ load 'rails/tasks/engine.rake'
20
+ load 'rails/tasks/statistics.rake'
21
+ load 'workarea/changelog.rake'
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+ task default: :test
32
+
33
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
34
+ require 'workarea/browse_option/version'
35
+
36
+ desc "Release version #{Workarea::BrowseOption::VERSION} of the gem"
37
+ task :release do
38
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
39
+
40
+ #Rake::Task['workarea:changelog'].execute
41
+ #system 'git add CHANGELOG.md'
42
+ #system 'git commit -m "Update CHANGELOG"'
43
+ #system 'git push origin HEAD'
44
+
45
+ system "git tag -a v#{Workarea::BrowseOption::VERSION} -m 'Tagging #{Workarea::BrowseOption::VERSION}'"
46
+ system 'git push --tags'
47
+
48
+ system 'gem build workarea-browse_option.gemspec'
49
+ system "gem push workarea-browse_option-#{Workarea::BrowseOption::VERSION}.gem"
50
+ system "gem push workarea-browse_option-#{Workarea::BrowseOption::VERSION}.gem --host #{host}"
51
+ system "rm workarea-browse_option-#{Workarea::BrowseOption::VERSION}.gem"
52
+ end
@@ -0,0 +1,25 @@
1
+ module Workarea
2
+ decorate Admin::CategorizationsController, with: :browse_option do
3
+ def create
4
+ ids = BrowseOptionIds.all_for(@product.model)
5
+
6
+ Catalog::Category.in(id: params[:category_ids]).each do |category|
7
+ ids.each { |id| category.product_ids.prepend(id) }
8
+ category.save!
9
+ end
10
+
11
+ flash[:success] = t('workarea.admin.categorizations.flash_messages.added')
12
+ redirect_to catalog_product_categorizations_path(@product)
13
+ end
14
+
15
+ def destroy
16
+ category = Catalog::Category.find_by(slug: params[:id])
17
+ ids = BrowseOptionIds.all_for(@product.model)
18
+ category.product_ids.reject! { |id| ids.include?(id) }
19
+ category.save!
20
+
21
+ flash[:success] = t('workarea.admin.categorizations.flash_messages.removed')
22
+ head :ok
23
+ end
24
+ end
25
+ end