Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Extract product properties to extension (#13690)
Damian Legawiec382c70df0978
diff --git a/docs/developer/upgrades/5.3-to-5.4.mdx b/docs/developer/upgrades/5.3-to-5.4.mdxindex 9054a213e5..5e617d801f 100644--- a/docs/developer/upgrades/5.3-to-5.4.mdx+++ b/docs/developer/upgrades/5.3-to-5.4.mdx@@ -236,3 +236,19 @@ If you rely on these features please run:```bashbundle add spree_multi_store```++### (Optional) Install Legacy Product Properties++Product Properties have been extracted from Spree core to a separate gem `spree_legacy_product_properties`. Product Properties were already deprecated in favor of [Metafields](/developer/core-concepts/metafields) and disabled by default since Spree 5.1.++If you have `product_properties_enabled: true` in your Spree configuration or rely on Product Properties in any way, install the extension:++ ```bash+ bundle add spree_legacy_product_properties+ ```++No data migration is needed — the gem uses the same database tables. All existing product properties, property definitions, and associations will continue to work as before.++<Warning>+ If you skip this step and had Product Properties enabled, any code referencing `product.product_properties`, `product.property()`, `product.set_property()`, or the admin Properties page will stop working.+</Warning>diff --git a/server/db/schema.rb b/server/db/schema.rbindex c21a6326fd..f00136b95f 100644--- a/server/db/schema.rb+++ b/server/db/schema.rb@@ -981,32 +981,6 @@ ActiveRecord::Schema[8.1].define(version: 2026_02_27_081642) dot.index ["promotion_rule_id", "product_id"], name: "index_products_promotion_rules_on_promotion_rule_and_product"end- create_table "spree_product_properties", force: :cascade do |t|- t.datetime "created_at", null: false- t.string "filter_param"- t.integer "position", default: 0- t.bigint "product_id"- t.bigint "property_id"- t.boolean "show_property", default: true- t.datetime "updated_at", null: false- t.string "value"- t.index ["filter_param"], name: "index_spree_product_properties_on_filter_param"- t.index ["position"], name: "index_spree_product_properties_on_position"- t.index ["product_id"], name: "index_product_properties_on_product_id"- t.index ["property_id", "product_id"], name: "index_spree_product_properties_on_property_id_and_product_id", unique: true- t.index ["property_id"], name: "index_spree_product_properties_on_property_id"- end-- create_table "spree_product_property_translations", force: :cascade do |t|- t.datetime "created_at", null: false- t.string "locale", null: false- t.bigint "spree_product_property_id", null: false- t.datetime "updated_at", null: false- t.string "value"- t.index ["locale"], name: "index_spree_product_property_translations_on_locale"- t.index ["spree_product_property_id", "locale"], name: "unique_product_property_id_per_locale", unique: true- end-create_table "spree_product_translations", force: :cascade do |t|t.datetime "created_at", null: falset.datetime "deleted_at", precision: nil@@ -1195,44 +1169,6 @@ ActiveRecord::Schema[8.1].define(version: 2026_02_27_081642) dot.index ["store_id"], name: "index_spree_promotions_stores_on_store_id"end- create_table "spree_properties", force: :cascade do |t|- t.datetime "created_at", null: false- t.string "display_on", default: "both"- t.string "filter_param"- t.boolean "filterable", default: false, null: false- t.integer "kind", default: 0- t.string "name"- t.integer "position", default: 0- t.string "presentation", null: false- t.jsonb "private_metadata"- t.jsonb "public_metadata"- t.datetime "updated_at", null: false- t.index ["filter_param"], name: "index_spree_properties_on_filter_param"- t.index ["filterable"], name: "index_spree_properties_on_filterable"- t.index ["name"], name: "index_spree_properties_on_name", unique: true- t.index ["position"], name: "index_spree_properties_on_position"- end-- create_table "spree_property_prototypes", force: :cascade do |t|- t.datetime "created_at", precision: nil- t.bigint "property_id"- t.bigint "prototype_id"- t.datetime "updated_at", precision: nil- t.index ["property_id"], name: "index_spree_property_prototypes_on_property_id"- t.index ["prototype_id", "property_id"], name: "index_property_prototypes_on_prototype_id_and_property_id", unique: true- t.index ["prototype_id"], name: "index_spree_property_prototypes_on_prototype_id"- end-- create_table "spree_property_translations", force: :cascade do |t|- t.datetime "created_at", null: false- t.string "locale", null: false- t.string "presentation"- t.bigint "spree_property_id", null: false- t.datetime "updated_at", null: false- t.index ["locale"], name: "index_spree_property_translations_on_locale"- t.index ["spree_property_id", "locale"], name: "unique_property_id_per_locale", unique: true- end-create_table "spree_prototype_taxons", force: :cascade do |t|t.datetime "created_at", precision: nilt.bigint "prototype_id"@@ -2069,9 +2005,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_02_27_081642) doadd_foreign_key "spree_option_value_translations", "spree_option_values"add_foreign_key "spree_payment_sources", "spree_payment_methods", column: "payment_method_id"add_foreign_key "spree_payment_sources", "spree_users", column: "user_id"- add_foreign_key "spree_product_property_translations", "spree_product_properties"add_foreign_key "spree_product_translations", "spree_products"- add_foreign_key "spree_property_translations", "spree_properties"add_foreign_key "spree_store_translations", "spree_stores"add_foreign_key "spree_taxon_translations", "spree_taxons"add_foreign_key "spree_taxonomy_translations", "spree_taxonomies"diff --git a/spree/admin/app/controllers/spree/admin/products_controller.rb b/spree/admin/app/controllers/spree/admin/products_controller.rbindex 36097d5f8b..58550b0381 100644--- a/spree/admin/app/controllers/spree/admin/products_controller.rb+++ b/spree/admin/app/controllers/spree/admin/products_controller.rb@@ -19,10 +19,8 @@ module Spreenew_action.before :build_master_pricesnew_action.before :build_master_stock_items- new_action.before :build_product_propertiesedit_action.before :build_master_pricesedit_action.before :build_master_stock_items- edit_action.before :build_product_propertiescreate.after :assign_master_imagesupdate.before :skip_updating_statusupdate.before :update_status@@ -271,16 +269,6 @@ module Spree{}end- def build_product_properties- return unless Spree::Config[:product_properties_enabled]-- Spree::Property.all.each do |property|- @product.product_properties.build(property: property) unless @product.product_properties.find do |product_property|- product_property.property_id == property.id- end- end- end-def assign_master_imagesreturn unless @product.master.persisted?diff --git a/spree/admin/app/controllers/spree/admin/properties_controller.rb b/spree/admin/app/controllers/spree/admin/properties_controller.rbdeleted file mode 100644index 04bde6297a..0000000000--- a/spree/admin/app/controllers/spree/admin/properties_controller.rb+++ /dev/null@@ -1,26 +0,0 @@-module Spree- module Admin- class PropertiesController < ResourceController- include ProductsBreadcrumbConcern- add_breadcrumb Spree.t(:properties), :admin_properties_path-- before_action :add_breadcrumbs-- protected-- def update_turbo_stream_enabled?- true- end-- def add_breadcrumbs- if @property.present? && @property.persisted?- add_breadcrumb @property.presentation, spree.edit_admin_property_path(@property)- end- end-- def permitted_resource_params- params.require(:property).permit(permitted_property_attributes)- end- end- end-enddiff --git a/spree/admin/app/helpers/spree/admin/products_helper.rb b/spree/admin/app/helpers/spree/admin/products_helper.rbindex 9bcc050120..8a9f0e6f1a 100644--- a/spree/admin/app/helpers/spree/admin/products_helper.rb+++ b/spree/admin/app/helpers/spree/admin/products_helper.rb@@ -111,9 +111,6 @@ module Spree[:admin, @search]end- def sorted_product_properties(product)- product.product_properties.sort_by { |product_property| product_property.property.position }- endendendenddiff --git a/spree/admin/app/views/spree/admin/products/_form.html.erb b/spree/admin/app/views/spree/admin/products/_form.html.erbindex 85f1fed380..a7e3cb6618 100644--- a/spree/admin/app/views/spree/admin/products/_form.html.erb+++ b/spree/admin/app/views/spree/admin/products/_form.html.erb@@ -7,8 +7,6 @@<% end unless @product.has_variants? %><%= render 'spree/admin/products/form/variants', f: f %><%= render 'spree/admin/products/form/inventory', f: f unless @product.has_variants? %>- <%= render 'spree/admin/products/form/properties', f: f if Spree::Config[:product_properties_enabled] %>-<%= render_admin_partials(:product_form_partials, f: f, product: @product) %></div><div class="col-span-12 md:col-span-4">diff --git a/spree/admin/app/views/spree/admin/products/form/_properties.html.erb b/spree/admin/app/views/spree/admin/products/form/_properties.html.erbdeleted file mode 100644index 08fc35349a..0000000000--- a/spree/admin/app/views/spree/admin/products/form/_properties.html.erb+++ /dev/null@@ -1,46 +0,0 @@-<div class="card mb-6">- <div class="card-header flex items-center justify-between">- <h5 class="card-title"><%= Spree.t(:properties) %></h5>-- <% if can?(:manage, Spree::Property) %>- <%= link_to_with_icon 'adjustments', Spree.t('admin.manage_properties'), spree.admin_properties_path, class: 'btn btn-sm btn-light' %>- <% end %>- </div>- <div class="card-body p-0">- <table class="table">- <thead>- <tr>- <th scope="col"><%= Spree.t(:property) %></th>- <th scope="col"><%= Spree.t(:value) %></th>- </tr>- </thead>- <tbody>- <%= f.fields_for :product_properties, sorted_product_properties(f.object) do |product_property_form| %>- <% property = product_property_form.object.property %>- <%= product_property_form.hidden_field :id %>- <%= product_property_form.hidden_field :property_id %>- <tr>- <td class="align-top pt-4 w-1/4">- <code><%= property.name %></code>- </td>- <td class="w-3/4">- <div class="form-group">- <% if property.long_text? %>- <%= product_property_form.text_area :value, { class: 'form-input', data: { controller: 'textarea-autogrow'} } %>- <% elsif property.number? %>- <%= product_property_form.number_field :value, class: 'form-input' %>- <% elsif property.rich_text? %>- <div class="trix-container">- <%= product_property_form.rich_text_area :value %>- </div>- <% else %>- <%= product_property_form.text_field :value, class: 'form-input' %>- <% end %>- </div>- </td>- </tr>- <% end %>- </tbody>- </table>- </div>-</div>\ No newline at end of filediff --git a/spree/admin/app/views/spree/admin/properties/_filters.html.erb b/spree/admin/app/views/spree/admin/properties/_filters.html.erbdeleted file mode 100644index bd918efbca..0000000000--- a/spree/admin/app/views/spree/admin/properties/_filters.html.erb+++ /dev/null@@ -1,5 +0,0 @@-<%= search_form_for [:admin, @search], class: "filter-wrap", data: {controller: "filters"} do |f| %>- <%= render 'spree/admin/shared/filters_search_bar', param: :name_cont, label: Spree.t(:name) %>- <%= render "spree/admin/shared/filter_badge_template" %>- <div data-filters-target="badgesContainer" class="filter-badges-container"></div>-<% end %>\ No newline at end of filediff --git a/spree/admin/app/views/spree/admin/properties/_form.html.erb b/spree/admin/app/views/spree/admin/properties/_form.html.erbdeleted file mode 100644index 86755b2ec7..0000000000--- a/spree/admin/app/views/spree/admin/properties/_form.html.erb+++ /dev/null@@ -1,8 +0,0 @@-<div data-controller="slug-form" class="card mb-6">- <div class="card-body">- <%= f.spree_text_field :presentation, data: { slug_form_target: :name, action: 'input->slug-form#updateUrlFromName' }, required: true, autofocus: f.object.new_record? %>- <%= f.spree_text_field :name, label: Spree.t(:internal_name), data: { slug_form_target: :url }, required: true %>- <%= f.spree_select :kind, options_for_select(Spree::Property.kinds.map{ |k| [k.first.humanize, k.first.to_sym] }, @object.kind) %>- <%= f.spree_select :display_on, display_on_options, { label: Spree.t(:display_on) } %>- </div>-</div>\ No newline at end of filediff --git a/spree/admin/app/views/spree/admin/properties/_table_header.html.erb b/spree/admin/app/views/spree/admin/properties/_table_header.html.erbdeleted file mode 100644index 7fb1174be8..0000000000--- a/spree/admin/app/views/spree/admin/properties/_table_header.html.erb+++ /dev/null@@ -1,9 +0,0 @@-<tr>- <th class="no-border handel-head"></th>- <th scope="col"><%= Spree.t(:internal_name) %></th>- <th scope="col"><%= Spree.t(:presentation) %></th>- <th scope="col"><%= Spree.t(:kind) %></th>- <th scope="col"><%= Spree.t(:products) %></th>- <th scope="col"><%= Spree.t(:visibility) %></th>- <th scope="col"></th>-</tr>\ No newline at end of filediff --git a/spree/admin/app/views/spree/admin/properties/_table_row.html.erb b/spree/admin/app/views/spree/admin/properties/_table_row.html.erbdeleted file mode 100644index c456f4130d..0000000000--- a/spree/admin/app/views/spree/admin/properties/_table_row.html.erb+++ /dev/null@@ -1,25 +0,0 @@-<tr id="<%= spree_dom_id property %>" data-controller="row-link" data-sortable-update-url="<%= spree.admin_property_path(property) %>">- <td class="w-5 move-handle text-center">- <%= icon('grip-vertical', class: 'rounded-md hover:bg-gray-100 p-2') %>- </td>- <td class="w-20 cursor-pointer py-0" data-action="click->row-link#openLink">- <code><%= property.name %></code>- </td>- <td class="w-20 cursor-pointer" data-action="click->row-link#openLink">- <%= link_to property.presentation, spree.edit_admin_property_path(property), class: 'no-underline flex items-center font-bold text-gray-900', data: { row_link_target: :link, turbo_frame: '_top' } %>- </td>- <td class="w-20 cursor-pointer" data-action="click->row-link#openLink">- <span class="badge badge-light"><%= property.kind.humanize %></span>- </td>- <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">- <%= property.products.count %>- </td>- <td>- <%= form_with model: property, url: admin_property_path(property), method: :patch, data: { controller: 'auto-submit' } do |f| %>- <%= f.select :display_on, display_on_options, {}, { class: 'form-select form-select-sm', data: { action: 'auto-submit#submit' } } %>- <% end %>- </td>- <td class="w-10 actions">- <%= link_to_edit(property, class: 'btn btn-light btn-sm', data: { turbo_frame: '_top' }) if can?(:edit, property) %>- </td>-</tr>diff --git a/spree/admin/app/views/spree/admin/properties/edit.html.erb b/spree/admin/app/views/spree/admin/properties/edit.html.erbdeleted file mode 100644index a275821684..0000000000--- a/spree/admin/app/views/spree/admin/properties/edit.html.erb+++ /dev/null@@ -1,2 +0,0 @@--<%= render 'spree/admin/shared/edit_resource' %>diff --git a/spree/admin/app/views/spree/admin/properties/index.html.erb b/spree/admin/app/views/spree/admin/properties/index.html.erbdeleted file mode 100644index aa95e8aa61..0000000000--- a/spree/admin/app/views/spree/admin/properties/index.html.erb+++ /dev/null@@ -1,22 +0,0 @@-<% content_for(:page_title) do %>- <%= Spree.t(:properties) %>-<% end %>--<% content_for(:page_alerts) do %>- <div class="alert alert-info">- Properties allow you to enrich your Product information.- </div>-<% end %>--<% content_for :page_actions do %>- <%= render_admin_partials(:properties_actions_partials) %>- <%= link_to_with_icon 'plus', Spree.t(:new_property), new_object_url, class: "btn btn-primary" if can?(:create, Spree::Property) %>-<% end %>--<%= render_admin_partials(:properties_header_partials) %>--<%= render 'spree/admin/shared/index_table', sortable: true %>--<p class="documentation-link-container">- <%= external_link_to "Learn more about properties", "https://spreecommerce.org/docs/user/manage-products/product-properties" %>-</p>\ No newline at end of filediff --git a/spree/admin/app/views/spree/admin/properties/new.html.erb b/spree/admin/app/views/spree/admin/properties/new.html.erbdeleted file mode 100644index 65a817edc9..0000000000--- a/spree/admin/app/views/spree/admin/properties/new.html.erb+++ /dev/null@@ -1 +0,0 @@-<%= render 'spree/admin/shared/new_resource' %>diff --git a/spree/admin/app/views/spree/admin/properties/update.turbo_stream.erb b/spree/admin/app/views/spree/admin/properties/update.turbo_stream.erbdeleted file mode 100644index d9fb79328e..0000000000--- a/spree/admin/app/views/spree/admin/properties/update.turbo_stream.erb+++ /dev/null@@ -1 +0,0 @@-<%= turbo_render_alerts %>\ No newline at end of filediff --git a/spree/admin/config/initializers/spree_admin_navigation.rb b/spree/admin/config/initializers/spree_admin_navigation.rbindex 71bc2c234f..dd643dbf4a 100644--- a/spree/admin/config/initializers/spree_admin_navigation.rb+++ b/spree/admin/config/initializers/spree_admin_navigation.rb@@ -126,12 +126,6 @@ Rails.application.config.after_initialize doactive: -> { %w[option_types option_values].include?(controller_name) },if: -> { can?(:manage, Spree::OptionType) }- # Properties- products.add :properties,- label: :properties,- url: :admin_properties_path,- position: 50,- if: -> { can?(:manage, Spree::Property) && Spree::Config.product_properties_enabled }end# Customers with submenudiff --git a/spree/admin/config/routes.rb b/spree/admin/config/routes.rbindex 088592affd..102335cc69 100644--- a/spree/admin/config/routes.rb+++ b/spree/admin/config/routes.rb@@ -1,7 +1,6 @@Spree::Core::Engine.add_routes donamespace :admin, path: Spree.admin_path do# product catalog- resources :properties, except: :showresources :option_types, except: :show doresources :option_values, only: [:update] docollection dodiff --git a/spree/admin/spec/controllers/spree/admin/products_controller_spec.rb b/spree/admin/spec/controllers/spree/admin/products_controller_spec.rbindex 89e45a3519..593a2f4713 100644--- a/spree/admin/spec/controllers/spree/admin/products_controller_spec.rb+++ b/spree/admin/spec/controllers/spree/admin/products_controller_spec.rb@@ -436,42 +436,6 @@ RSpec.describe Spree::Admin::ProductsController, type: :controller doendend- context 'with product properties' do- let!(:property_1) { create(:property, name: 'material', presentation: 'Material') }- let!(:property_2) { create(:property, name: 'short_description', presentation: 'Short description') }- let!(:property_3) { create(:property, name: 'care', presentation: 'Care') }-- let(:product_params) do- {- name: 'Product',- product_properties_attributes: {- '0' => {- property_id: property_1.id,- value: 'Wool'- },- '1' => {- property_id: property_2.id,- value: 'Short description'- },- '2' => {- property_id: property_3.id,- value: ''- }- },- shipping_category_id: shipping_category.id- }- end-- it 'creates product properties correctly' do- subject-- product = Spree::Product.last- expect(product.properties.count).to eq 2- expect(product.property('material')).to eq 'Wool'- expect(product.property('short_description')).to eq 'Short description'- end- end-context 'with multiple stores' dolet(:store_2) { create(:store) }@@ -1078,46 +1042,6 @@ RSpec.describe Spree::Admin::ProductsController, type: :controller doendend- context 'with product properties' do- let!(:property_1) { create(:property, name: 'material', presentation: 'Material') }- let!(:property_2) { create(:property, name: 'short_description', presentation: 'Short description') }- let!(:property_3) { create(:property, name: 'care', presentation: 'Care') }-- let(:product_property_1) { create(:product_property, product: product, property: property_1, value: 'Wool') }- let(:product_property_2) { create(:product_property, product: product, property: property_2, value: 'Short description') }-- let(:product_params) do- {- product_properties_attributes: {- '0' => {- id: product_property_1.id,- property_id: property_1.id,- value: 'Better Wool'- },- '1' => {- id: product_property_2.id,- property_id: property_2.id,- value: ''- },- '2' => {- property_id: property_3.id,- value: 'new value'- }- }- }- end-- it 'updates 1 product property, creates 1 product property and destroys 1 product property' do- send_request-- product = Spree::Product.last- expect(product.properties.count).to eq 2- expect(product.property('material')).to eq 'Better Wool'- expect(product.property('short_description')).to be_nil- expect(product.property('care')).to eq 'new value'- end- end-context 'with multi-store taxon preservation' dolet(:other_store) { create(:store) }let(:store_taxonomy) { create(:taxonomy, store: store) }diff --git a/spree/admin/spec/controllers/spree/admin/properties_controller_spec.rb b/spree/admin/spec/controllers/spree/admin/properties_controller_spec.rbdeleted file mode 100644index b732cc09c8..0000000000--- a/spree/admin/spec/controllers/spree/admin/properties_controller_spec.rb+++ /dev/null@@ -1,54 +0,0 @@-require 'spec_helper'--describe Spree::Admin::PropertiesController, type: :controller do- stub_authorization!-- render_views-- let(:store) { @default_store }-- before do- allow(controller).to receive(:current_store).and_return(store)- end-- describe '#index' do- let!(:property) { create(:property, name: 'Ingredients', presentation: 'Product Ingredients') }-- it 'renders index' do- get :index- expect(response).to have_http_status(:ok)-- expect(assigns(:collection).to_a.count).to eq(1)- expect(assigns(:collection).to_a).to eq([property])- end- end-- describe '#create ' do- it 'creates a property' do- expect { post :create, params: {property: {name: 'New Property', presentation: 'New Presentation', kind: 'long_text', display_on: 'both'}} }.to change(Spree::Property, :count).by(1)- property = Spree::Property.last- expect(property.name).to eq('new-property')- expect(property.presentation).to eq('New Presentation')- expect(property.kind).to eq('long_text')- expect(property.display_on).to eq('both')-- expect(response).to redirect_to(spree.edit_admin_property_path(property))- end- end-- describe '#update' do- let(:property) { create(:property) }-- it 'updates the property' do- put :update, params: {id: property.id, property: { name: 'New Name'}}-- expect(property.reload.name).to eq('new-name')- end-- it 'can set property position' do- put :update, params: {id: property.id, property: { position: 2 }}-- expect(property.reload.position).to eq(2)- end- end-enddiff --git a/spree/admin/spec/features/spree/admin/products/edit/properties_spec.rb b/spree/admin/spec/features/spree/admin/products/edit/properties_spec.rbdeleted file mode 100644index 6a57af4bc7..0000000000--- a/spree/admin/spec/features/spree/admin/products/edit/properties_spec.rb+++ /dev/null@@ -1,40 +0,0 @@-require 'spec_helper'--describe 'Product Properties', type: :feature, js: true do- stub_authorization!-- let(:store) { Spree::Store.default }- let(:product) { create(:product, stores: [store]) }-- let!(:brand_property) { create(:property, name: 'brand', presentation: 'Brand', position: 1) }- let!(:material_property) { create(:property, name: 'material', presentation: 'Material', position: 2) }-- before do- product.set_property('brand', 'Epsilon')-- Spree::Config[:product_properties_enabled] = true- end-- after do- Spree::Config[:product_properties_enabled] = false- end-- it 'shows associated properties in the form plus a new property' do- visit spree.edit_admin_product_path(product)- expect(page).to have_content('brand')- expect(page).to have_field('product_product_properties_attributes_0_value', with: 'Epsilon')- expect(page).to have_content('material')- expect(page).to have_field('product_product_properties_attributes_1_value', with: '')-- fill_in 'product_product_properties_attributes_1_value', with: 'Cotton'- within('#page-header') { click_button 'Update' }-- expect(page).to have_content('successfully updated!')-- expect(product.reload.property('material')).to eq('Cotton')- expect(product.property('brand')).to eq('Epsilon')-- expect(page).to have_field('product_product_properties_attributes_0_value', with: 'Epsilon')- expect(page).to have_field('product_product_properties_attributes_1_value', with: 'Cotton')- end-enddiff --git a/spree/admin/spec/features/spree/admin/products/properties_spec.rb b/spree/admin/spec/features/spree/admin/products/properties_spec.rbdeleted file mode 100644index cce8cbbc2b..0000000000--- a/spree/admin/spec/features/spree/admin/products/properties_spec.rb+++ /dev/null@@ -1,56 +0,0 @@-require 'spec_helper'--describe 'Properties spec', type: :feature do- stub_authorization!-- describe 'creating property' do- before do- visit spree.new_admin_property_path- end-- it 'allows to create new property' do- fill_in 'property_presentation', with: 'Country of Origin'- select('Long text', from: 'Kind')- click_button 'Create'-- expect(page).to have_content 'successfully created!'-- property = Spree::Property.last- expect(property.presentation).to eq('Country of Origin')- expect(property.name).to eq('country-of-origin')- expect(property.kind).to eq('long_text')- end- end-- context 'listing properties', js: true do- before do- create(:property, name: 'ingredients', presentation: 'Ingredients', position: 2)- create(:property, name: 'materials', presentation: 'Materials', position: 1)- end-- it 'lists existing properties' do- visit spree.admin_properties_path- within('table') do- within_row(1) do- expect(page).to have_content('materials')- end- within_row(2) do- expect(page).to have_content('ingredients')- end- end- end-- it 'can change property display on from list view' do- visit spree.admin_properties_path- within_row(1) do- expect(page).to have_content('materials')- select 'Only on admin panel', from: 'property_display_on'- end-- expect(page).to have_content('successfully updated!')-- property = Spree::Property.find_by(name: 'materials')- expect(property.display_on).to eq('back_end')- end- end-enddiff --git a/spree/admin/spec/helpers/spree/admin/products_helper_spec.rb b/spree/admin/spec/helpers/spree/admin/products_helper_spec.rbindex 6bbb4ba15b..f63a121e7a 100644--- a/spree/admin/spec/helpers/spree/admin/products_helper_spec.rb+++ b/spree/admin/spec/helpers/spree/admin/products_helper_spec.rb@@ -49,22 +49,4 @@ describe Spree::Admin::ProductsHelper doendend- describe '#sorted_product_properties' do- let(:product) { create(:product) }-- context 'when the product has product properties' do- let!(:product_property1) { create(:product_property, product: product, property: create(:property, position: 2)) }- let!(:product_property2) { create(:product_property, product: product, property: create(:property, position: 1)) }-- it 'returns the product properties sorted by position' do- expect(sorted_product_properties(product)).to eq([product_property2, product_property1])- end- end-- context 'when the product has no product properties' do- it 'returns an empty array' do- expect(sorted_product_properties(product)).to eq([])- end- end- endenddiff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rbindex 980d26cadd..888aef918c 100644--- a/spree/api/lib/spree/api/dependencies.rb+++ b/spree/api/lib/spree/api/dependencies.rb@@ -213,8 +213,8 @@ module Spreeplatform_promotion_action_serializer: 'Spree::Api::V2::Platform::PromotionActionSerializer',platform_promotion_category_serializer: 'Spree::Api::V2::Platform::PromotionCategorySerializer',platform_promotion_rule_serializer: 'Spree::Api::V2::Platform::PromotionRuleSerializer',- platform_promotion_serializer: 'Spree::Api::V2::Platform::PromotionSerializer',platform_property_serializer: 'Spree::Api::V2::Platform::PropertySerializer',+ platform_promotion_serializer: 'Spree::Api::V2::Platform::PromotionSerializer',platform_prototype_serializer: 'Spree::Api::V2::Platform::PrototypeSerializer',platform_refund_reason_serializer: 'Spree::Api::V2::Platform::RefundReasonSerializer',platform_refund_serializer: 'Spree::Api::V2::Platform::RefundSerializer',diff --git a/spree/core/app/finders/spree/product_properties/find_available.rb b/spree/core/app/finders/spree/product_properties/find_available.rbdeleted file mode 100644index 420905d207..0000000000--- a/spree/core/app/finders/spree/product_properties/find_available.rb+++ /dev/null@@ -1,20 +0,0 @@-module Spree- module ProductProperties- class FindAvailable- include ProductFilterable-- def initialize(scope: ProductProperty.spree_base_scopes, products_scope: Product.spree_base_scopes)- @scope = scope- @products_scope = products_scope- end-- def execute- find_available(scope, products_scope).includes(:translations)- end-- private-- attr_reader :scope, :products_scope- end- end-enddiff --git a/spree/core/app/finders/spree/products/find.rb b/spree/core/app/finders/spree/products/find.rbindex 1c54a7f293..87b7cc1b41 100644--- a/spree/core/app/finders/spree/products/find.rb+++ b/spree/core/app/finders/spree/products/find.rb@@ -19,7 +19,6 @@ module Spree@sort_by = params.dig(:sort_by)@deleted = params.dig(:filter, :show_deleted)@discontinued = params.dig(:filter, :show_discontinued)- @properties = params.dig(:filter, :properties)@in_stock = params.dig(:filter, :in_stock)@backorderable = params.dig(:filter, :backorderable)@purchasable = params.dig(:filter, :purchasable)@@ -46,7 +45,6 @@ module Spreeproducts = by_slug(products)products = by_options(products)products = by_option_value_ids(products)- products = by_properties(products)products = by_tags(products)products = include_deleted(products)products = show_only_stock(products)@@ -63,7 +61,7 @@ module Spreeprivateattr_reader :ids, :skus, :price, :currency, :taxons, :concat_taxons, :name, :options, :option_value_ids, :scope,- :sort_by, :deleted, :discontinued, :properties, :store, :in_stock, :backorderable, :purchasable, :tags,+ :sort_by, :deleted, :discontinued, :store, :in_stock, :backorderable, :purchasable, :tags,:query, :vendor_ids, :out_of_stock, :slug, :taxonomiesdef query?@@ -114,10 +112,6 @@ module Spreesort_by.present?end- def properties?- properties.present? && properties.values.reject(&:empty?).present?- end-def vendor_ids?vendor_ids.present?end@@ -224,27 +218,6 @@ module Spreeproducts.where(id: product_ids)end- def by_properties(products)- return products unless properties?-- product_ids = []- index = 0-- properties.to_unsafe_hash.each do |property_filter_param, product_properties_values|- next if property_filter_param.blank? || product_properties_values.empty?-- values = product_properties_values.split(',').reject(&:empty?).uniq.map(&:parameterize)-- next if values.empty?-- ids = scope.unscope(:order, :includes).with_property_values(property_filter_param, values).ids- product_ids = index == 0 ? ids : product_ids & ids- index += 1- end-- products.where(id: product_ids)- end-def by_tags(products)return products if tags.empty?diff --git a/spree/core/app/models/concerns/spree/product_scopes.rb b/spree/core/app/models/concerns/spree/product_scopes.rbindex 108a12c21e..c2f4b340c6 100644--- a/spree/core/app/models/concerns/spree/product_scopes.rb+++ b/spree/core/app/models/concerns/spree/product_scopes.rb@@ -31,21 +31,6 @@ module Spreeendend- def self.property_conditions(property)- properties_table = Property.table_name-- case property- when Property then { "#{properties_table}.id" => property.id }- when Integer then { "#{properties_table}.id" => property }- else- if Property.column_for_attribute('id').type == :uuid- ["#{properties_table}.name = ? OR #{properties_table}.id = ?", property, property]- else- { "#{properties_table}.name" => property }- end- end- end-add_simple_scopes simple_scopesadd_search_scope :ascend_by_master_price do@@ -149,33 +134,6 @@ module Spreeorder(Arel.sql("#{min_position_sql} ASC"))end- # a scope that finds all products having property specified by name, object or id- add_search_scope :with_property do |property|- joins(:properties).where(property_conditions(property))- end-- # a simple test for product with a certain property-value pairing- # note that it can test for properties with NULL values, but not for absent values- add_search_scope :with_property_value do |property, value|- if Spree.use_translations?- joins(:properties).- join_translation_table(Property).- join_translation_table(ProductProperty).- where(ProductProperty.translation_table_alias => { value: value }).- where(property_conditions(property))- else- joins(:properties).- where(ProductProperty.table_name => { value: value }).- where(property_conditions(property))- end- end-- add_search_scope :with_property_values do |property_filter_param, property_values|- joins(product_properties: :property).- where(Property.table_name => { filter_param: property_filter_param }).- where(ProductProperty.table_name => { filter_param: property_values.map(&:parameterize) })- end-add_search_scope :with_option do |option|if option.is_a?(OptionType)joins(:option_types).where(spree_option_types: { id: option.id })@@ -226,13 +184,10 @@ module Spreewhere(Spree::OptionValue.table_name => { id: actual_ids })end- # Finds all products which have either:- # 1) have an option value with the name matching the one given- # 2) have a product property with a value matching the one given+ # Finds all products which have an option value with the name matching the one givenadd_search_scope :with do |value|includes(variants: :option_values).- includes(:product_properties).- where("#{OptionValue.table_name}.name = ? OR #{ProductProperty.table_name}.value = ?", value, value)+ where("#{OptionValue.table_name}.name = ?", value)end# Finds all products that have a name containing the given words.diff --git a/spree/core/app/models/spree/ability.rb b/spree/core/app/models/spree/ability.rbindex 0cb683437f..f436e9889e 100644--- a/spree/core/app/models/spree/ability.rb+++ b/spree/core/app/models/spree/ability.rb@@ -162,8 +162,6 @@ module Spreecan :manage, ::Spree::Address, user_id: user.id if user.persisted?can [:read, :destroy], ::Spree::CreditCard, user_id: user.idcan :read, ::Spree::Product- can :read, ::Spree::ProductProperty- can :read, ::Spree::Propertycan :create, ::Spree.user_classcan [:show, :update, :destroy], ::Spree.user_class, id: user.idcan :read, ::Spree::Statediff --git a/spree/core/app/models/spree/exports/products.rb b/spree/core/app/models/spree/exports/products.rbindex 27825c8017..93b7dbe2a1 100644--- a/spree/core/app/models/spree/exports/products.rb+++ b/spree/core/app/models/spree/exports/products.rb@@ -4,7 +4,6 @@ module Spree# to avoid N+1 queriesdef scope_includesincludes = [:tax_category, :master, :option_types, { taxons: :taxonomy }, { variants_including_master: variant_includes }]- includes << { product_properties: [:property] } if Spree::Config[:product_properties_enabled]includes << { metafields: :metafield_definition }includesend@@ -28,14 +27,9 @@ module Spreedef csv_headersheaders = Spree::CSV::ProductVariantPresenter::CSV_HEADERS.dup- headers += properties_headers if Spree::Config[:product_properties_enabled]headers += metafields_headers@csv_headers ||= headersend-- def properties_headers- @properties_headers ||= Spree::Property.order(:position).count.times.flat_map { |n| ["property#{n + 1}_name", "property#{n + 1}_value"] }- endendendenddiff --git a/spree/core/app/models/spree/permission_sets/default_customer.rb b/spree/core/app/models/spree/permission_sets/default_customer.rbindex a52915e143..4fbb6a8f16 100644--- a/spree/core/app/models/spree/permission_sets/default_customer.rb+++ b/spree/core/app/models/spree/permission_sets/default_customer.rb@@ -15,8 +15,6 @@ module Spreecan :read, Spree::OptionTypecan :read, Spree::OptionValuecan :read, Spree::Product- can :read, Spree::ProductProperty- can :read, Spree::Propertycan :read, Spree::Statecan :read, Spree::Storecan :read, Spree::Taxondiff --git a/spree/core/app/models/spree/permission_sets/product_display.rb b/spree/core/app/models/spree/permission_sets/product_display.rbindex 7a3f6f8abe..0ef8851c97 100644--- a/spree/core/app/models/spree/permission_sets/product_display.rb+++ b/spree/core/app/models/spree/permission_sets/product_display.rb@@ -14,8 +14,6 @@ module Spreecan [:read, :admin], Spree::Variantcan [:read, :admin], Spree::OptionTypecan [:read, :admin], Spree::OptionValue- can [:read, :admin], Spree::Property- can [:read, :admin], Spree::ProductPropertycan [:read, :admin], Spree::Metafieldcan [:read, :admin], Spree::Taxoncan [:read, :admin], Spree::Taxonomydiff --git a/spree/core/app/models/spree/permission_sets/product_management.rb b/spree/core/app/models/spree/permission_sets/product_management.rbindex 8ee1b38023..f811820dac 100644--- a/spree/core/app/models/spree/permission_sets/product_management.rb+++ b/spree/core/app/models/spree/permission_sets/product_management.rb@@ -14,8 +14,6 @@ module Spreecan :manage, Spree::Variantcan :manage, Spree::OptionTypecan :manage, Spree::OptionValue- can :manage, Spree::Property- can :manage, Spree::ProductPropertycan :manage, Spree::Taxoncan :manage, Spree::Taxonomycan :manage, Spree::Classificationdiff --git a/spree/core/app/models/spree/product.rb b/spree/core/app/models/spree/product.rbindex 9d4a243cc4..182425a4ae 100644--- a/spree/core/app/models/spree/product.rb+++ b/spree/core/app/models/spree/product.rb@@ -72,9 +72,6 @@ module Spreehas_many :product_option_types, -> { order(:position) }, dependent: :destroy, inverse_of: :producthas_many :option_types, through: :product_option_types- has_many :product_properties, dependent: :destroy, inverse_of: :product- has_many :properties, through: :product_properties-has_many :classifications, -> { order(created_at: :asc) }, dependent: :delete_all, inverse_of: :producthas_many :taxons, through: :classifications, before_remove: :remove_taxonhas_many :taxonomies, through: :taxons@@ -215,9 +212,6 @@ module Spreeattr_accessor :option_values_hash- accepts_nested_attributes_for :product_properties, allow_destroy: true, reject_if: lambda { |pp|- pp[:property_id].blank? || (pp[:id].blank? && pp[:value].blank?)- }accepts_nested_attributes_for(:variants,allow_destroy: true,@@ -236,7 +230,7 @@ module Spreeself.whitelisted_ransackable_attributes = %w[description name slug discontinue_on status available_on created_at updated_at]self.whitelisted_ransackable_associations = %w[taxons stores variants_including_master master variants tags labels- shipping_category classifications option_types properties]+ shipping_category classifications option_types]self.whitelisted_ransackable_scopes = %w[not_discontinued search_by_name in_taxon price_betweenmulti_search in_stock_items out_of_stock_items with_option_value_idsascend_by_price descend_by_price]@@ -417,7 +411,7 @@ module Spree# Returns the short description for the product# @return [String]def storefront_description- property('short_description') || description+ descriptionend# Returns tax category for Product@@ -522,45 +516,6 @@ module Spreevariants.active(current_currency).joins(:option_value_variants)end- def property(property_name)- Spree::Deprecation.warn("Product properties are deprecated and will be removed in Spree 6.0. Please use Metafields instead")- if product_properties.loaded?- product_properties.detect { |property| property.property.name == property_name }.try(:value)- else- product_properties.joins(:property).find_by(spree_properties: { name: property_name }).try(:value)- end- end-- def set_property(property_name, property_value, property_presentation = property_name)- Spree::Deprecation.warn("Product properties are deprecated and will be removed in Spree 6.0. Please use Metafields instead")- property_name = property_name.to_s.parameterize- ApplicationRecord.transaction do- # Manual first_or_create to work around Mobility bug- property = if Property.where(name: property_name).exists?- existing_property = Property.where(name: property_name).first- existing_property.presentation ||= property_presentation- existing_property.save- existing_property- else- Property.create(name: property_name, presentation: property_presentation)- end-- product_property = if ProductProperty.where(product: self, property: property).exists?- ProductProperty.where(product: self, property: property).first- else- ProductProperty.new(product: self, property: property)- end-- product_property.value = property_value- product_property.save!- end- end-- def remove_property(property_name)- Spree::Deprecation.warn("Product properties are deprecated and will be removed in Spree 6.0. Please use Metafields instead")- product_properties.joins(:property).find_by(spree_properties: { name: property_name.parameterize })&.destroy- end-def total_on_hand@total_on_hand ||= if any_variants_not_track_inventory?BigDecimal::INFINITY@@ -682,7 +637,7 @@ module Spreedef to_csv(store = nil)store ||= stores.default || stores.first- properties_for_csv = if Spree::Config[:product_properties_enabled]+ properties_for_csv = if respond_to?(:product_properties) && Spree::Config.respond_to?(:product_properties_enabled) && Spree::Config[:product_properties_enabled]Spree::Property.order(:position).flat_map do |property|[property.name,@@ -726,9 +681,6 @@ module Spreedef add_associations_from_prototypeif prototype_id && prototype = Spree::Prototype.find_by(id: prototype_id)- prototype.properties.each do |property|- product_properties.create(property: property, value: 'Placeholder')- endself.option_types = prototype.option_typesself.taxons = prototype.taxonsenddiff --git a/spree/core/app/models/spree/product_property.rb b/spree/core/app/models/spree/product_property.rbdeleted file mode 100644index 5e0db6be75..0000000000--- a/spree/core/app/models/spree/product_property.rb+++ /dev/null@@ -1,51 +0,0 @@-module Spree- class ProductProperty < Spree.base_class- include Spree::FilterParam- include Spree::TranslatableResource-- if Spree.always_use_translations?- TRANSLATABLE_FIELDS = %i[value filter_param].freeze- translates(*TRANSLATABLE_FIELDS)- else- TRANSLATABLE_FIELDS = %i[value].freeze- translates(*TRANSLATABLE_FIELDS, column_fallback: true)- end-- self::Translation.class_eval do- normalizes :value, with: ->(value) { value&.to_s&.squish&.presence }- end-- normalizes :value, with: ->(value) { value&.to_s&.squish&.presence }-- acts_as_list scope: :product-- with_options inverse_of: :product_properties do- belongs_to :product, touch: true, class_name: 'Spree::Product'- belongs_to :property, touch: true, class_name: 'Spree::Property'- end-- validates :property, presence: true- validates :property_id, uniqueness: { scope: :product_id }- validates :value, presence: true-- default_scope { order(:position) }-- scope :filterable, -> { joins(:property).where(Property.table_name => { filterable: true }) }- scope :for_products, ->(products) { where(product_id: products) }- scope :sort_by_property_position, -> {- unscope(:order).joins(:property).order(Spree::Property.table_name => { position: :asc })- }-- self.whitelisted_ransackable_attributes = ['value', 'filter_param']- self.whitelisted_ransackable_associations = ['property']-- # virtual attributes for use with AJAX completion stuff- delegate :name, :presentation, to: :property, prefix: true, allow_nil: true-- protected-- def param_candidate- value- end- end-enddiff --git a/spree/core/app/models/spree/property.rb b/spree/core/app/models/spree/property.rbdeleted file mode 100644index 71d9357294..0000000000--- a/spree/core/app/models/spree/property.rb+++ /dev/null@@ -1,86 +0,0 @@-module Spree- class Property < Spree.base_class- include Spree::FilterParam- include Spree::Metadata- include Spree::ParameterizableName- include Spree::UniqueName- include Spree::DisplayOn- include Spree::TranslatableResource-- TRANSLATABLE_FIELDS = %i[presentation].freeze- translates(*TRANSLATABLE_FIELDS, column_fallback: !Spree.always_use_translations?)-- self::Translation.class_eval do- normalizes :presentation, with: ->(value) { value&.to_s&.squish&.presence }- end-- acts_as_list-- has_many :property_prototypes, class_name: 'Spree::PropertyPrototype'- has_many :prototypes, through: :property_prototypes, class_name: 'Spree::Prototype'-- has_many :product_properties, dependent: :delete_all, inverse_of: :property- has_many :products, through: :product_properties-- validates :name, :presentation, presence: true-- default_scope { order(:position) }- scope :sorted, -> { order(:name) }- scope :filterable, -> { where(filterable: true) }-- KIND_OPTIONS = { short_text: 0, long_text: 1, number: 2, rich_text: 3 }.freeze- enum :kind, KIND_OPTIONS-- DEPENDENCY_UPDATE_FIELDS = [:presentation, :name, :kind, :filterable, :display_on, :position].freeze-- after_touch :touch_all_products- after_update :touch_all_products, if: -> { DEPENDENCY_UPDATE_FIELDS.any? { |field| saved_changes.key?(field) } }- after_save :ensure_product_properties_have_filter_params-- self.whitelisted_ransackable_attributes = ['presentation', 'filterable']-- def uniq_values(product_properties_scope: nil)- with_uniq_values_cache_key(product_properties_scope) do- properties = product_properties- properties = properties.where(id: product_properties_scope) if product_properties_scope.present?- properties.where('value IS NOT NULL AND value != ?', '').pluck(:filter_param, :value).uniq- end- end-- # Returns the metafield type for the property kind- # @return [String] eg. 'Spree::Metafields::ShortText'- def kind_to_metafield_type- case kind- when 'short_text'- 'Spree::Metafields::ShortText'- when 'long_text'- 'Spree::Metafields::LongText'- when 'number'- 'Spree::Metafields::Number'- when 'rich_text'- 'Spree::Metafields::RichText'- else- 'Spree::Metafields::ShortText'- end- end-- private-- def touch_all_products- products.touch_all- end-- def with_uniq_values_cache_key(product_properties_scope, &block)- return block.call if product_properties_scope.present?-- uniq_values_cache_key = ['property-uniq-values', cache_key_with_version]- Rails.cache.fetch(uniq_values_cache_key) { block.call }- end-- def ensure_product_properties_have_filter_params- return unless filterable?-- product_properties.where(filter_param: [nil, '']).where('value IS NOT NULL AND value != ?', '').find_each(&:save)- end- end-enddiff --git a/spree/core/app/models/spree/property_prototype.rb b/spree/core/app/models/spree/property_prototype.rbdeleted file mode 100644index 20f2c6bdd9..0000000000--- a/spree/core/app/models/spree/property_prototype.rb+++ /dev/null@@ -1,9 +0,0 @@-module Spree- class PropertyPrototype < Spree.base_class- belongs_to :prototype, class_name: 'Spree::Prototype'- belongs_to :property, class_name: 'Spree::Property'-- validates :prototype, :property, presence: true- validates :prototype_id, uniqueness: { scope: :property_id }- end-enddiff --git a/spree/core/app/models/spree/prototype.rb b/spree/core/app/models/spree/prototype.rbindex 336ad4b65e..aacb86e4d8 100644--- a/spree/core/app/models/spree/prototype.rb+++ b/spree/core/app/models/spree/prototype.rb@@ -4,9 +4,6 @@ module Spreeinclude Spree::Metadata- has_many :property_prototypes, class_name: 'Spree::PropertyPrototype'- has_many :properties, through: :property_prototypes, class_name: 'Spree::Property'-has_many :option_type_prototypes, class_name: 'Spree::OptionTypePrototype'has_many :option_types, through: :option_type_prototypes, class_name: 'Spree::OptionType'diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rbindex dab1df7c12..c6eae80984 100644--- a/spree/core/app/models/spree/store.rb+++ b/spree/core/app/models/spree/store.rb@@ -75,7 +75,6 @@ module Spreehas_many :store_products, class_name: 'Spree::StoreProduct'has_many :products, through: :store_products, class_name: 'Spree::Product'- has_many :product_properties, through: :products, class_name: 'Spree::ProductProperty'has_many :variants, through: :products, class_name: 'Spree::Variant', source: :variants_including_masterhas_many :stock_items, through: :variants, class_name: 'Spree::StockItem'has_many :inventory_units, through: :variants, class_name: 'Spree::InventoryUnit'diff --git a/spree/core/app/presenters/spree/filters/properties_presenter.rb b/spree/core/app/presenters/spree/filters/properties_presenter.rbdeleted file mode 100644index ee4c951cd1..0000000000--- a/spree/core/app/presenters/spree/filters/properties_presenter.rb+++ /dev/null@@ -1,23 +0,0 @@-module Spree- module Filters- class PropertiesPresenter- def initialize(product_properties_scope:)- @product_properties = product_properties_scope.includes(:property)- end-- def to_a- grouped_options.map do |property, product_properties|- PropertyPresenter.new(property: property, product_properties: product_properties)- end- end-- private-- attr_reader :product_properties-- def grouped_options- product_properties.group_by(&:property)- end- end- end-enddiff --git a/spree/core/app/presenters/spree/filters/property_presenter.rb b/spree/core/app/presenters/spree/filters/property_presenter.rbdeleted file mode 100644index 5b6aded0c2..0000000000--- a/spree/core/app/presenters/spree/filters/property_presenter.rb+++ /dev/null@@ -1,42 +0,0 @@-module Spree- module Filters- class PropertyPresenter- def initialize(property:, product_properties:)- @property = property- @product_properties = product_properties- end-- attr_reader :product_properties-- delegate_missing_to :property-- def uniq_values- property.uniq_values(product_properties_scope: product_properties)- end-- def to_h- {- id: property.id,- name: property.name,- presentation: property.presentation,- values: values_hash- }- end-- private-- attr_reader :property-- def values_hash- value_hashes = uniq_values.map do |filter_param, value|- {- value: value,- filter_param: filter_param- }- end-- value_hashes.sort_by { |e| e[:value] }- end- end- end-enddiff --git a/spree/core/app/services/spree/products/duplicator.rb b/spree/core/app/services/spree/products/duplicator.rbindex 1c5f05d205..0a0595817b 100644--- a/spree/core/app/services/spree/products/duplicator.rb+++ b/spree/core/app/services/spree/products/duplicator.rb@@ -13,8 +13,6 @@ module Spreenew_product.send(:duplicate_extra, product) if new_product.respond_to?(:duplicate_extra)new_product.save- new_product.product_properties = duplicate_properties(product.product_properties) if new_product.persisted?-new_product.persisted? ? success(new_product) : failure(new_product, duplicate_error_message(new_product))end@@ -89,16 +87,6 @@ module Spreenew_imageend- def duplicate_properties(product_properties)- product_properties.map do |prop|- new_prop = prop.dup- new_prop.product = nil- new_prop.created_at = nil- new_prop.updated_at = nil- new_prop- end- end-def sku_generator(sku)return '' if sku.blank?diff --git a/spree/core/app/services/spree/products/prepare_nested_attributes.rb b/spree/core/app/services/spree/products/prepare_nested_attributes.rbindex 61d7cc2ad7..6f7f639988 100644--- a/spree/core/app/services/spree/products/prepare_nested_attributes.rb+++ b/spree/core/app/services/spree/products/prepare_nested_attributes.rb@@ -61,18 +61,6 @@ module Spreeendend- # mark resource properties to be removed- # when value is left blank- if params[:product_properties_attributes].present?- params[:product_properties_attributes].each do |key, product_property_params|- next unless product_property_params[:id].present?- next if product_property_params[:value].present?-- # https://api.rubyonrails.org/v7.1.3.4/classes/ActiveRecord/NestedAttributes/ClassMethods.html- params[:product_properties_attributes][key]['_destroy'] = '1'- end- end-# ensure there is at least one storeparams[:store_ids] = [store.id] if params[:store_ids].blank?diff --git a/spree/core/db/migrate/20210914000000_spree_four_three.rb b/spree/core/db/migrate/20210914000000_spree_four_three.rbindex af49f78300..0056f4eb02 100644--- a/spree/core/db/migrate/20210914000000_spree_four_three.rb+++ b/spree/core/db/migrate/20210914000000_spree_four_three.rb@@ -407,22 +407,6 @@ class SpreeFourThree < ActiveRecord::Migration[5.2]t.index ["promotion_rule_id", "product_id"], name: "index_products_promotion_rules_on_promotion_rule_and_product"end- create_table "spree_product_properties", force: :cascade do |t|- t.string "value"- t.bigint "product_id"- t.bigint "property_id"- t.datetime "created_at", precision: 6, null: false- t.datetime "updated_at", precision: 6, null: false- t.integer "position", default: 0- t.boolean "show_property", default: true- t.string "filter_param"- t.index ["filter_param"], name: "index_spree_product_properties_on_filter_param"- t.index ["position"], name: "index_spree_product_properties_on_position"- t.index ["product_id"], name: "index_product_properties_on_product_id"- t.index ["property_id", "product_id"], name: "index_spree_product_properties_on_property_id_and_product_id", unique: true- t.index ["property_id"], name: "index_spree_product_properties_on_property_id"- end-create_table "spree_products", force: :cascade do |t|t.string "name", default: "", null: falset.text "description"@@ -563,28 +547,6 @@ class SpreeFourThree < ActiveRecord::Migration[5.2]t.index ["store_id"], name: "index_spree_promotions_stores_on_store_id"end- create_table "spree_properties", force: :cascade do |t|- t.string "name"- t.string "presentation", null: false- t.datetime "created_at", precision: 6, null: false- t.datetime "updated_at", precision: 6, null: false- t.boolean "filterable", default: false, null: false- t.string "filter_param"- t.index ["filter_param"], name: "index_spree_properties_on_filter_param"- t.index ["filterable"], name: "index_spree_properties_on_filterable"- t.index ["name"], name: "index_spree_properties_on_name"- end-- create_table "spree_property_prototypes", force: :cascade do |t|- t.bigint "prototype_id"- t.bigint "property_id"- t.datetime "created_at"- t.datetime "updated_at"- t.index ["property_id"], name: "index_spree_property_prototypes_on_property_id"- t.index ["prototype_id", "property_id"], name: "index_property_prototypes_on_prototype_id_and_property_id", unique: true- t.index ["prototype_id"], name: "index_spree_property_prototypes_on_prototype_id"- end-create_table "spree_prototype_taxons", force: :cascade do |t|t.bigint "taxon_id"t.bigint "prototype_id"diff --git a/spree/core/db/migrate/20210915064329_add_metadata_to_spree_multiple_tables.rb b/spree/core/db/migrate/20210915064329_add_metadata_to_spree_multiple_tables.rbindex 56ca9ae768..0fe557026d 100644--- a/spree/core/db/migrate/20210915064329_add_metadata_to_spree_multiple_tables.rb+++ b/spree/core/db/migrate/20210915064329_add_metadata_to_spree_multiple_tables.rb@@ -4,7 +4,6 @@ class AddMetadataToSpreeMultipleTables < ActiveRecord::Migration[5.2]spree_assetsspree_option_typesspree_option_values- spree_propertiesspree_promotionsspree_payment_methodsspree_shipping_methodsdiff --git a/spree/core/db/migrate/20230109084253_create_product_property_translations.rb b/spree/core/db/migrate/20230109084253_create_product_property_translations.rbdeleted file mode 100644index 7d929c9fdd..0000000000--- a/spree/core/db/migrate/20230109084253_create_product_property_translations.rb+++ /dev/null@@ -1,24 +0,0 @@-class CreateProductPropertyTranslations < ActiveRecord::Migration[6.1]- def change- if ActiveRecord::Base.connection.table_exists? 'spree_product_property_translations'- # manually check for index since Rails if_exists does not always work correctly- if ActiveRecord::Migration.connection.index_exists?(:spree_product_property_translations, :spree_product_property_id)- remove_index :spree_product_property_translations, column: :spree_product_property_id, if_exists: true- end- else- create_table :spree_product_property_translations do |t|- # Translated attribute(s)- t.string :value-- t.string :locale, null: false- t.references :spree_product_property, null: false, foreign_key: true, index: false-- t.timestamps- end-- add_index :spree_product_property_translations, :locale, name: :index_spree_product_property_translations_on_locale- end-- add_index :spree_product_property_translations, [:spree_product_property_id, :locale], name: :unique_product_property_id_per_locale, unique: true- end-enddiff --git a/spree/core/db/migrate/20230109105943_create_property_translations.rb b/spree/core/db/migrate/20230109105943_create_property_translations.rbdeleted file mode 100644index ea1b95de37..0000000000--- a/spree/core/db/migrate/20230109105943_create_property_translations.rb+++ /dev/null@@ -1,24 +0,0 @@-class CreatePropertyTranslations < ActiveRecord::Migration[6.1]- def change- if ActiveRecord::Base.connection.table_exists?('spree_property_translations')- # manually check for index since Rails if_exists does not always work correctly- if ActiveRecord::Migration.connection.index_exists?(:spree_property_translations, :spree_property_id)- remove_index :spree_property_translations, column: :spree_property_id, if_exists: true- end- else- create_table :spree_property_translations do |t|- # Translated attribute(s)- t.string :presentation-- t.string :locale, null: false- t.references :spree_property, null: false, foreign_key: true, index: false-- t.timestamps- end-- add_index :spree_property_translations, :locale, name: :index_spree_property_translations_on_locale- end-- add_index :spree_property_translations, [:spree_property_id, :locale], name: :unique_property_id_per_locale, unique: true- end-enddiff --git a/spree/core/db/migrate/20240914153106_add_display_on_to_spree_properties.rb b/spree/core/db/migrate/20240914153106_add_display_on_to_spree_properties.rbdeleted file mode 100644index f8a970cc18..0000000000--- a/spree/core/db/migrate/20240914153106_add_display_on_to_spree_properties.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddDisplayOnToSpreeProperties < ActiveRecord::Migration[6.1]- def change- add_column :spree_properties, :display_on, :string, default: 'both', if_not_exists: true- end-enddiff --git a/spree/core/db/migrate/20240915144935_add_position_to_spree_properties.rb b/spree/core/db/migrate/20240915144935_add_position_to_spree_properties.rbdeleted file mode 100644index 2d8dcb5dea..0000000000--- a/spree/core/db/migrate/20240915144935_add_position_to_spree_properties.rb+++ /dev/null@@ -1,6 +0,0 @@-class AddPositionToSpreeProperties < ActiveRecord::Migration[6.1]- def change- add_column :spree_properties, :position, :integer, default: 0, if_not_exists: true- add_index :spree_properties, :position, if_not_exists: true- end-enddiff --git a/spree/core/db/migrate/20250127083740_add_kind_to_spree_properties.rb b/spree/core/db/migrate/20250127083740_add_kind_to_spree_properties.rbdeleted file mode 100644index e9bc5750f4..0000000000--- a/spree/core/db/migrate/20250127083740_add_kind_to_spree_properties.rb+++ /dev/null@@ -1,5 +0,0 @@-class AddKindToSpreeProperties < ActiveRecord::Migration[6.1]- def change- add_column :spree_properties, :kind, :integer, default: 0, if_not_exists: true- end-enddiff --git a/spree/core/db/migrate/20250730154601_add_unique_index_on_spree_properties_name.rb b/spree/core/db/migrate/20250730154601_add_unique_index_on_spree_properties_name.rbdeleted file mode 100644index 442f6d3116..0000000000--- a/spree/core/db/migrate/20250730154601_add_unique_index_on_spree_properties_name.rb+++ /dev/null@@ -1,24 +0,0 @@-class AddUniqueIndexOnSpreePropertiesName < ActiveRecord::Migration[7.2]- def change- # we don't need to run this migration in multi-tenant mode as it's already handled there- return if defined?(SpreeMultiTenant)-- # Rename duplicated properties- duplicates = Spree::Property.select(:name).group(:name).having('COUNT(*) > 1').reorder('').pluck(:name)-- duplicates.each do |duplicate_name|- properties = Spree::Property.where(name: duplicate_name)-- properties.each_with_index do |property, index|- next if index == 0 # Keep the first one unchanged-- new_name = "#{duplicate_name}_#{index}"- property.update_columns(name: new_name, updated_at: Time.current)- end- end-- # Add indexes- remove_index :spree_properties, :name, if_exists: true- add_index :spree_properties, :name, unique: true, if_not_exists: true- end-enddiff --git a/spree/core/lib/generators/spree/cursor_rules/templates/spree_rules.mdc b/spree/core/lib/generators/spree/cursor_rules/templates/spree_rules.mdcindex d5fd22c3e1..3a601fc24a 100644--- a/spree/core/lib/generators/spree/cursor_rules/templates/spree_rules.mdc+++ b/spree/core/lib/generators/spree/cursor_rules/templates/spree_rules.mdc@@ -77,9 +77,7 @@ class Spree::Product < Spree.base_classinclude Spree::Metafieldshas_many :variants, class_name: 'Spree::Variant', dependent: :destroy- has_many :product_properties, class_name: 'Spree::ProductProperty', dependent: :destroy- has_many :properties, through: :product_properties, source: :property-+scope :available, -> { where(available_on: ..Time.current) }validates :name, presence: truediff --git a/spree/core/lib/spree/core/configuration.rb b/spree/core/lib/spree/core/configuration.rbindex 13f63bafc4..81a641e2c1 100644--- a/spree/core/lib/spree/core/configuration.rb+++ b/spree/core/lib/spree/core/configuration.rb@@ -82,7 +82,6 @@ module Spreepreference :mailer_logo, :string, deprecated: truepreference :max_level_in_taxons_menu, :integer, deprecated: truepreference :non_expiring_credit_types, :array, default: []- preference :product_properties_enabled, :boolean, default: false # enable legacy product propertiespreference :products_per_page, :integer, default: 12preference :require_master_price, :boolean, default: falsepreference :restock_inventory, :boolean, default: true # Determines if a return item is restocked automatically once it has been receiveddiff --git a/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb b/spree/core/lib/spree/core/controller_helpers/strong_parameters.rbindex 5e2e2d6be1..6f7bffc875 100644--- a/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb+++ b/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb@@ -34,8 +34,7 @@ module Spreedef permitted_product_attributespermitted_attributes.product_attributes + [variants_attributes: permitted_variant_attributes + ['id', :_destroy],- master_attributes: permitted_variant_attributes + ['id'],- product_properties_attributes: permitted_product_properties_attributes + ['id', :_destroy]+ master_attributes: permitted_variant_attributes + ['id']]enddiff --git a/spree/core/lib/spree/core/engine.rb b/spree/core/lib/spree/core/engine.rbindex e3b5099b91..2df84209f0 100644--- a/spree/core/lib/spree/core/engine.rb+++ b/spree/core/lib/spree/core/engine.rb@@ -202,7 +202,6 @@ module SpreeRails.application.config.spree.translatable_resources = [Spree::OptionType,Spree::Product,- Spree::Property,Spree::Taxon,Spree::Taxonomy,Spree::Store,diff --git a/spree/core/lib/spree/permitted_attributes.rb b/spree/core/lib/spree/permitted_attributes.rbindex f49481aedc..cd9fad9603 100644--- a/spree/core/lib/spree/permitted_attributes.rb+++ b/spree/core/lib/spree/permitted_attributes.rb@@ -44,8 +44,6 @@ module Spree:promotion_attributes,:promotion_rule_attributes,:promotion_action_attributes,- :product_properties_attributes,- :property_attributes,:refund_attributes,:refund_reason_attributes,:reimbursement_attributes,@@ -177,8 +175,6 @@ module Spree@@price_list_attributes = [:name, :description, :match_policy, :starts_at, :ends_at, :status, :position]- @@product_properties_attributes = [:property_name, :property_id, :value, :position, :_destroy]-@@product_attributes = [:name, :description, :available_on, :make_active_at, :discontinue_on, :permalink, :meta_description,:meta_keywords, :meta_title, :price, :sku, :deleted_at, :prototype_id,@@ -204,8 +200,6 @@ module Spree@@promotion_action_attributes = [:type, :calculator_type, calculator_attributes: {}, promotion_action_line_items_attributes: [:id, :promotion_action_id, :variant_id, :quantity, :_destroy]]- @@property_attributes = [:name, :presentation, :position, :kind, :display_on]-@@refund_attributes = [:amount, :refund_reason_id]@@refund_reason_attributes = [:name, :active, :mutable]diff --git a/spree/core/lib/spree/testing_support/factories/product_factory.rb b/spree/core/lib/spree/testing_support/factories/product_factory.rbindex ec89c4ce68..0e3b0a7c22 100644--- a/spree/core/lib/spree/testing_support/factories/product_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/product_factory.rb@@ -50,13 +50,6 @@ FactoryBot.define dofactory :product_with_option_types doafter(:create) { |product| create(:product_option_type, product: product) }end- factory :product_with_properties do- after(:create) do |product|- property = create(:property, :brand)- create(:product_property, product: product, property: property, value: 'Epsilon')- end- end-factory :digital_product dotrack_inventory { false }shipping_category { |r| Spree::ShippingCategory.digital || r.association(:digital_shipping_category) }diff --git a/spree/core/lib/spree/testing_support/factories/product_property_factory.rb b/spree/core/lib/spree/testing_support/factories/product_property_factory.rbdeleted file mode 100644index 06c5382375..0000000000--- a/spree/core/lib/spree/testing_support/factories/product_property_factory.rb+++ /dev/null@@ -1,7 +0,0 @@-FactoryBot.define do- factory :product_property, class: Spree::ProductProperty do- product- value { "val-#{rand(50)}" }- property- end-enddiff --git a/spree/core/lib/spree/testing_support/factories/property_factory.rb b/spree/core/lib/spree/testing_support/factories/property_factory.rbdeleted file mode 100644index 706f2d9ef9..0000000000--- a/spree/core/lib/spree/testing_support/factories/property_factory.rb+++ /dev/null@@ -1,28 +0,0 @@-FactoryBot.define do- factory :property, class: Spree::Property do- sequence(:name) { |n| "baseball_cap_color_#{n}" }- presentation { 'cap color' }-- trait :filterable do- filterable { true }- end-- trait :brand do- name { 'brand' }- presentation { 'Brand' }- filter_param { 'brand' }- end-- trait :manufacturer do- name { 'manufacturer' }- presentation { 'Manufacturer' }- filter_param { 'manufacturer' }- end-- trait :material do- name { 'material' }- presentation { 'Material' }- filter_param { 'material' }- end- end-enddiff --git a/spree/core/lib/spree/testing_support/factories/prototype_factory.rb b/spree/core/lib/spree/testing_support/factories/prototype_factory.rbindex 9b27c22a65..025357e43a 100644--- a/spree/core/lib/spree/testing_support/factories/prototype_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/prototype_factory.rb@@ -1,11 +1,9 @@FactoryBot.define dofactory :prototype, class: Spree::Prototype doname { 'Baseball Cap' }- properties { [build(:property)] }endfactory :prototype_with_option_types, class: Spree::Prototype doname { 'Baseball Cap' }- properties { [build(:property)] }option_types { [build(:option_type)] }endenddiff --git a/spree/core/lib/tasks/core.rake b/spree/core/lib/tasks/core.rakeindex 1fb13ab8ef..be6e5cab59 100644--- a/spree/core/lib/tasks/core.rake+++ b/spree/core/lib/tasks/core.rake@@ -36,26 +36,6 @@ namespace :db doendend- desc 'Migrate product properties to metafields'- task migrate_product_properties_to_metafields: :environment do |_t, _args|- Spree::Property.find_each do |property|- metafield_definition = Spree::MetafieldDefinition.find_or_initialize_by(- namespace: 'properties',- key: property.name,- resource_type: 'Spree::Product'- )- metafield_definition.assign_attributes(- metafield_type: property.kind_to_metafield_type,- display_on: property.display_on- )- metafield_definition.save!-- property.product_properties.includes(:product).find_each do |product_property|- product_property.product.set_metafield("properties.#{property.name}", product_property.value)- puts "Migrated #{property.name} to product #{product_property.product.id}"- end- end- endendnamespace :core dodiff --git a/spree/core/spec/finders/spree/product_properties/find_available_spec.rb b/spree/core/spec/finders/spree/product_properties/find_available_spec.rbdeleted file mode 100644index 5ada92f4a8..0000000000--- a/spree/core/spec/finders/spree/product_properties/find_available_spec.rb+++ /dev/null@@ -1,52 +0,0 @@-require 'spec_helper'--module Spree- RSpec.describe ProductProperties::FindAvailable do- let(:finder) { described_class.new }-- let(:brand) { create(:property, :brand, :filterable) }- let(:alpha_brand) { create(:product_property, property: brand, value: 'Alpha') }- let(:beta_brand) { create(:product_property, property: brand, value: 'Beta') }- let(:gamma_brand) { create(:product_property, property: brand, value: 'Gamma') }-- let(:manufacturer) { create(:property, :manufacturer, :filterable) }- let(:wilson_manufacturer) { create(:product_property, property: manufacturer, value: 'Wilson') }- let(:jerseys_manufacturer) { create(:product_property, property: manufacturer, value: 'Jerseys') }-- describe '#execute' do- subject(:available_properties) { finder.execute }-- it 'finds available Product Properties' do- expect(available_properties).to contain_exactly(- alpha_brand, beta_brand, gamma_brand,- wilson_manufacturer, jerseys_manufacturer- )- end-- context 'when given a predefined scope' do- let(:finder) { described_class.new(scope: scope) }- let(:scope) { ProductProperty.where(id: [beta_brand, jerseys_manufacturer]) }-- it 'finds available Product Properties with respect to a predefined scope' do- expect(available_properties).to contain_exactly(beta_brand, jerseys_manufacturer)- end- end-- context 'when given a predefined products scope' do- let(:finder) { described_class.new(products_scope: products_scope) }- let(:products_scope) { Product.where(id: [product_1, product_2, product_3]) }-- let(:product_1) { alpha_brand.product }- let(:product_2) { gamma_brand.product }- let(:product_3) { wilson_manufacturer.product }-- it 'finds filterable Product Properties with respect to a predefined Products scope' do- expect(available_properties).to contain_exactly(- alpha_brand, gamma_brand,- wilson_manufacturer- )- end- end- end- end-enddiff --git a/spree/core/spec/finders/spree/products/find_spec.rb b/spree/core/spec/finders/spree/products/find_spec.rbindex 66c4029bec..e53e63b679 100644--- a/spree/core/spec/finders/spree/products/find_spec.rb+++ b/spree/core/spec/finders/spree/products/find_spec.rb@@ -372,73 +372,6 @@ module Spreeendend- describe 'filter by properties' do- subject(:products) do- described_class.new(- scope: Spree::Product.all,- params: params- ).execute- end-- let(:params) do- { filter: { properties: ActionController::Parameters.new(properties_param) } }- end-- let(:brand) { create(:property, :brand) }- let(:manufacturer) { create(:property, :manufacturer) }- let(:material) { create(:property, :material) }-- let!(:product_1) do- create(- :product,- product_properties: [- create(:product_property, property: brand, value: 'Alpha'),- create(:product_property, property: manufacturer, value: 'Wilson')- ]- )- end-- let!(:product_2) do- create(- :product,- product_properties: [- create(:product_property, property: brand, value: 'Beta'),- create(:product_property, property: manufacturer, value: 'Jerseys')- ]- )- end-- let(:product_3) do- create(- :product,- product_properties: [- create(:product_property, property: brand, value: 'Alpha')- ]- )- end-- before do- create(:product, product_properties: [create(:product_property, property: manufacturer, value: 'Jerseys')])- create(:product, product_properties: [create(:product_property, property: material, value: '100% Cotton')])- end-- context 'when filtering by one Property' do- let(:properties_param) { { brand: 'alpha,beta,gamma' } }-- it 'finds Products matching any of Property values' do- expect(products).to contain_exactly(product_1, product_2, product_3)- end- end-- context 'when filtering by many Properties' do- let(:properties_param) { { brand: 'alpha,beta,gamma', manufacturer: 'wilson,jerseys' } }-- it 'finds Products matching any of Property values, but for all given Properties' do- expect(products).to contain_exactly(product_1, product_2)- end- end- end-context 'ordered' docontext 'default' dosubject(:products) dodiff --git a/spree/core/spec/models/spree/exports/products_spec.rb b/spree/core/spec/models/spree/exports/products_spec.rbindex 224c24fd89..f5a0ddae3d 100644--- a/spree/core/spec/models/spree/exports/products_spec.rb+++ b/spree/core/spec/models/spree/exports/products_spec.rb@@ -26,11 +26,7 @@ RSpec.describe Spree::Exports::Products, type: :model doenddescribe '#csv_headers' do- context 'when product_properties_enabled is false and no metafields' do- before do- allow(Spree::Config).to receive(:[]).with(:product_properties_enabled).and_return(false)- end-+ context 'when no metafields' doit 'returns product variant headers without properties' doexpected_headers = ['product_id',@@ -79,67 +75,7 @@ RSpec.describe Spree::Exports::Products, type: :model doendend- context 'when product_properties_enabled is true' do- before do- allow(Spree::Config).to receive(:[]).with(:product_properties_enabled).and_return(true)- create(:property)- end-- it 'includes property headers' do- expected_headers = [- 'product_id',- 'sku',- 'name',- 'slug',- 'status',- 'vendor_name',- 'brand_name',- 'description',- 'meta_title',- 'meta_description',- 'meta_keywords',- 'tags',- 'labels',- 'price',- 'compare_at_price',- 'currency',- 'width',- 'height',- 'depth',- 'dimensions_unit',- 'weight',- 'weight_unit',- 'available_on',- 'discontinue_on',- 'track_inventory',- 'inventory_count',- 'inventory_backorderable',- 'tax_category',- 'shipping_category',- 'image1_src',- 'image2_src',- 'image3_src',- 'option1_name',- 'option1_value',- 'option2_name',- 'option2_value',- 'option3_name',- 'option3_value',- 'category1',- 'category2',- 'category3',- 'property1_name',- 'property1_value'- ]- expect(export.csv_headers).to eq(expected_headers)- end- end-context 'when metafields exist' do- before do- allow(Spree::Config).to receive(:[]).with(:product_properties_enabled).and_return(false)- end-let!(:metafield_definition) { create(:metafield_definition, resource_type: 'Spree::Product', namespace: 'custom', key: 'field1') }it 'includes metafield headers' dodiff --git a/spree/core/spec/models/spree/permission_sets/product_management_spec.rb b/spree/core/spec/models/spree/permission_sets/product_management_spec.rbindex d14cca746f..2020b35986 100644--- a/spree/core/spec/models/spree/permission_sets/product_management_spec.rb+++ b/spree/core/spec/models/spree/permission_sets/product_management_spec.rb@@ -26,14 +26,6 @@ RSpec.describe Spree::PermissionSets::ProductManagement doexpect(ability.can?(:manage, Spree::OptionValue)).to be trueend- it 'grants manage access to Property' do- expect(ability.can?(:manage, Spree::Property)).to be true- end-- it 'grants manage access to ProductProperty' do- expect(ability.can?(:manage, Spree::ProductProperty)).to be true- end-it 'grants manage access to Taxon' doexpect(ability.can?(:manage, Spree::Taxon)).to be trueenddiff --git a/spree/core/spec/models/spree/product/scopes_spec.rb b/spree/core/spec/models/spree/product/scopes_spec.rbindex 6dc578e254..be42a7648e 100644--- a/spree/core/spec/models/spree/product/scopes_spec.rb+++ b/spree/core/spec/models/spree/product/scopes_spec.rb@@ -95,104 +95,6 @@ describe 'Product scopes', type: :model doendend- context 'property scopes' do- let(:name) { property.name }- let(:value) { 'Alpha' }-- let(:product_property) { create(:product_property, property: property, value: value) }- let(:property) { create(:property, :brand) }-- before do- product.product_properties << product_property- end-- context 'with_property' do- subject(:with_property) { Spree::Product.method(:with_property) }-- it "finds by a property's name" do- expect(with_property.call(name).count).to eq(1)- end-- it "doesn't find any properties with an unknown name" do- expect(with_property.call('fake').count).to eq(0)- end-- it 'finds by a property' do- expect(with_property.call(property).count).to eq(1)- end-- it 'finds by an id' do- expect(with_property.call(property.id).count).to eq(1)- end-- it 'cannot find a property with an unknown id' do- expect(with_property.call(0).count).to eq(0)- end- end-- context 'with_property_value' do- subject(:with_property_value) { Spree::Product.method(:with_property_value) }-- it "finds by a property's name" do- expect(with_property_value.call(name, value).count).to eq(1)- end-- it "cannot find by an unknown property's name" do- expect(with_property_value.call('fake', value).count).to eq(0)- end-- it 'cannot find with a name by an incorrect value' do- expect(with_property_value.call(name, 'fake').count).to eq(0)- end-- it 'finds by a property' do- expect(with_property_value.call(property, value).count).to eq(1)- end-- it 'cannot find with a property by an incorrect value' do- expect(with_property_value.call(property, 'fake').count).to eq(0)- end-- it 'finds by an id with a value' do- expect(with_property_value.call(property.id, value).count).to eq(1)- end-- it 'cannot find with an invalid id' do- expect(with_property_value.call(0, value).count).to eq(0)- end-- it 'cannot find with an invalid value' do- expect(with_property_value.call(property.id, 'fake').count).to eq(0)- end- end-- context 'with_property_values' do- subject(:with_property_values) { Spree::Product.method(:with_property_values) }-- let!(:product_2) { create(:product, product_properties: [product_2_property], stores: [store]) }- let(:product_2_property) { create(:product_property, property: property, value: value_2) }- let(:value_2) { 'Beta 10%' }-- before do- create(:product, product_properties: [create(:product_property, property: property, value: '20% Gamma')], stores: [store])- end-- it 'finds by property values' do- expect(with_property_values.call(name, [value, value_2, 'non_existent'])).to contain_exactly(- product, product_2- )- end-- it 'cannot find with an invalid property name' do- expect(with_property_values.call('fake', [value, value_2])).to be_empty- end-- it 'cannot find with invalid property values' do- expect(with_property_values.call(name, ['fake'])).to be_empty- end- end- end-context '#add_simple_scopes' dolet(:simple_scopes) { [:ascend_by_updated_at, :descend_by_name] }diff --git a/spree/core/spec/models/spree/product_property_spec.rb b/spree/core/spec/models/spree/product_property_spec.rbdeleted file mode 100644index 8a67d8b606..0000000000--- a/spree/core/spec/models/spree/product_property_spec.rb+++ /dev/null@@ -1,74 +0,0 @@-require 'spec_helper'--describe Spree::ProductProperty, type: :model do- describe '#validations' do- let!(:product_property) { create(:product_property) }-- it 'should not create duplicated property for product' do- duplicated_property = product_property.product.product_properties.new(property: product_property.property)-- expect(duplicated_property.save).to be_falsy- expect(duplicated_property.errors.messages).to have_key(:property_id)- end-- context 'value field' do- let(:product_property) { build(:product_property, value: nil) }-- it 'validates presence' do- expect(product_property.save).to be_falsy- expect(product_property.errors.messages).to have_key(:value)- end- end- end-- describe 'translations' do- let!(:product_property) { create(:product_property, value: 'EN value') }-- before do- Mobility.with_locale(:pl) do- product_property.update!(value: 'PL value')- end- end-- let(:product_property_pl_translation) { product_property.translations.find_by(locale: 'pl') }-- it 'translates product property fields' do- expect(product_property.value).to eq('EN value')-- expect(product_property_pl_translation).to be_present- expect(product_property_pl_translation.value).to eq('PL value')- end- end-- context 'touching' do- let(:product_property) { create(:product_property) }-- it 'updates product' do- expect(product_property.product).to receive(:touch)- product_property.touch- end-- it 'updates property' do- expect(product_property.property).to receive(:touch)- product_property.touch- end- end-- context 'ransackable_associations' do- it { expect(described_class.whitelisted_ransackable_associations).to include('property') }- end-- context 'setting param' do- subject { build(:product_property, value: '90% Cotton 10% Elastan') }-- it { expect { subject.save! }.to change(subject, :filter_param).from(nil).to('90-cotton-10-elastan') }- end-- context 'setting value' do- subject { build(:product_property, value: ' 90% Cotton 10% Elastan ') }-- it 'normalizes value by stripping whitespace' do- expect(subject.value).to eq('90% Cotton 10% Elastan')- end- end-enddiff --git a/spree/core/spec/models/spree/product_spec.rb b/spree/core/spec/models/spree/product_spec.rbindex 17a0e9b57f..dd457f8a6a 100644--- a/spree/core/spec/models/spree/product_spec.rb+++ b/spree/core/spec/models/spree/product_spec.rb@@ -418,72 +418,9 @@ describe Spree::Product, type: :model doendend- context 'properties' do+ context 'promotions' dolet(:product) { create(:product, stores: [store]) }- it 'properly assigns properties' do- product.set_property('the_prop', 'value1')- expect(product.property('the_prop')).to eq('value1')-- product.set_property('the_prop', 'value2')- expect(product.property('the_prop')).to eq('value2')-- I18n.with_locale(:pl) do- product.set_property('the_prop', 'translated-value1', 'the_translated_prop')- expect(product.property('the_prop')).to eq('translated-value1')-- product.set_property('the_prop', 'translated-value2')- expect(product.property('the_prop')).to eq('translated-value2')-- expect(product.properties[0].presentation).to eq('the_translated_prop')- end-- expect(product.properties[0].presentation).to eq('the_prop')- end-- it 'does not create duplicate properties when set_property is called' do- expect do- product.set_property('the_prop', 'value2')- product.save- product.reload- end.not_to change(product.properties, :length)-- expect do- product.set_property('the_prop_new', 'value')- product.save- product.reload- expect(product.property('the_prop_new')).to eq('value')- end.to change { product.properties.length }.by(1)- end-- context 'optional property_presentation' do- subject { Spree::Property.where(name: 'foo').first.presentation }-- let(:name) { 'foo' }- let(:presentation) { 'baz' }-- describe 'is not used' do- before { product.set_property(name, 'bar') }-- it { is_expected.to eq name }- end-- describe 'is used' do- before { product.set_property(name, 'bar', presentation) }-- it { is_expected.to eq presentation }- end- end-- # Regression test for #2455- it "does not overwrite properties' presentation names" do- Spree::Property.create!(name: 'foo', presentation: "Foo's Presentation Name")- product.set_property('foo', 'value1')- product.set_property('bar', 'value2')- expect(Spree::Property.where(name: 'foo').first.presentation).to eq("Foo's Presentation Name")- expect(Spree::Property.where(name: 'bar').first.presentation).to eq('bar')- end-# Regression test for #4416describe '#possible_promotions' dolet!(:possible_promotion) { create(:promotion, advertise: true, starts_at: 1.day.ago) }@@ -510,13 +447,6 @@ describe Spree::Product, type: :model dobefore { product.prototype_id = prototype.id }- context 'when prototype is supplied' do- it 'creates properties based on the prototype' do- product.save- expect(product.properties.count).to eq(1)- end- end-context 'when prototype with option types is supplied' dodef build_option_type_with_values(name, values)values.each_with_object(create(:option_type, name: name)) do |val, ot|@@ -1278,24 +1208,13 @@ describe Spree::Product, type: :model dodescribe '#to_csv' dolet(:store) { Spree::Store.default }let(:product) { create(:product, stores: [store]) }- let(:property) { create(:property, name: 'my-property', position: 1) }- let(:product_property) { create(:product_property, property: property, product: product, value: 'MyValue') }let(:taxon) { create(:taxon, name: 'My Taxon') }before do- product_propertyproduct.taxons << taxonendcontext 'when product has no variants' do- before do- Spree::Config[:product_properties_enabled] = true- end-- after do- Spree::Config[:product_properties_enabled] = false- end-it 'returns an array with one line of CSV data' docsv_lines = product.to_csv(store)expect(csv_lines.size).to eq(1)@@ -1303,7 +1222,6 @@ describe Spree::Product, type: :model docsv_line = csv_lines.firstexpect(csv_line).to include(product.name)expect(csv_line).to include(product.master.sku)- expect(csv_line.last(5)).to eq([taxon.pretty_name, nil, nil, "my-property", "MyValue"])endenddiff --git a/spree/core/spec/models/spree/property_spec.rb b/spree/core/spec/models/spree/property_spec.rbdeleted file mode 100644index 15bb33eab6..0000000000--- a/spree/core/spec/models/spree/property_spec.rb+++ /dev/null@@ -1,211 +0,0 @@-require 'spec_helper'--describe Spree::Property, type: :model do- let(:store) { @default_store }-- it_behaves_like 'metadata'-- describe 'translations' do- let!(:property) { create(:property, name: 'brand', presentation: 'Brand') }-- before do- Mobility.with_locale(:pl) do- property.update!(presentation: 'Marka')- end- end-- let(:property_pl_translation) { property.translations.find_by(locale: 'pl') }-- it 'translates property fields' do- expect(property.presentation).to eq('Brand')-- expect(property_pl_translation).to be_present- expect(property_pl_translation.presentation).to eq('Marka')- end- end-- describe 'scopes' do- let!(:properties) { create_list(:property, 2, display_on: 'both') }- let!(:frontend_properties) { create_list(:property, 2, display_on: 'front_end') }- let!(:backend_properties) { create_list(:property, 2, display_on: 'back_end') }-- describe '.available' do- subject { described_class.available }-- it { is_expected.to match_array(properties) }- end-- describe '.available_on_front_end' do- subject { described_class.available_on_front_end }-- it { is_expected.to match_array(properties + frontend_properties) }- end-- describe '.available_on_back_end' do- subject { described_class.available_on_back_end }-- it { is_expected.to match_array(properties + backend_properties) }- end- end-- describe 'callbacks' do- describe '#normalize_name' do- let!(:option_type) { build(:option_type, name: 'Shirt Size') }-- it 'should parameterize the name' do- option_type.name = 'Shirt Size'- option_type.save!- expect(option_type.name).to eq('shirt-size')- end- end- end-- context 'setting filter param' do- subject { build(:property, name: 'Brand Name') }-- it { expect { subject.save! }.to change(subject, :filter_param).from(nil).to('brand-name') }- end-- describe '#uniq_values' do- let(:property) { create(:property) }-- before do- create(:product_property, property: property, value: 'Some Value')- create(:product_property, property: property, value: 'Some Value')- create(:product_property, property: property, value: 'Another 10% Value')- end-- it { expect(property.uniq_values).to match_array([['some-value', 'Some Value'], ['another-10-value', 'Another 10% Value']]) }-- context 'when narrowing the scope of product properties' do- let!(:product_property_1) { create(:product_property, property: property, value: 'Some 10% Value') }- let!(:product_property_2) { create(:product_property, property: property, value: 'Some 10% Value') }- let!(:product_property_3) { create(:product_property, property: property, value: 'Another 20% Value') }-- let(:scope) { [product_property_1, product_property_2, product_property_3] }-- let(:scope_uniq_values) do- [- ['some-10-value', 'Some 10% Value'],- ['another-20-value', 'Another 20% Value']- ]- end-- it { expect(property.uniq_values(product_properties_scope: scope)).to match_array(scope_uniq_values) }- end-- context 'when caching' do- it 'correctly returns uniq values' do- expect(property.uniq_values).to match_array([['some-value', 'Some Value'], ['another-10-value', 'Another 10% Value']])-- product_property_1 = create(:product_property, property: property, value: 'Some 20% Value')- expect(property.uniq_values).to match_array(- [- ['some-value', 'Some Value'],- ['another-10-value', 'Another 10% Value'],- ['some-20-value', 'Some 20% Value']- ]- )-- product_property_2 = create(:product_property, property: property, value: 'Another 20% Value')- product_property_3 = create(:product_property, property: property, value: 'Another 30% Value')-- scope = [product_property_1, product_property_2]- other_scope = [product_property_2, product_property_3]-- expect(property.uniq_values(product_properties_scope: scope)).to match_array(- [- ['some-20-value', 'Some 20% Value'],- ['another-20-value', 'Another 20% Value']- ]- )-- expect(property.uniq_values(product_properties_scope: other_scope)).to match_array(- [- ['another-20-value', 'Another 20% Value'],- ['another-30-value', 'Another 30% Value']- ]- )- end- end- end-- describe '#ensure_product_properties_have_filter_params' do- let(:property) { create(:property) }- let(:product) { create(:product, stores: [store]) }- let(:product_2) { create(:product, stores: [store]) }-- let(:product_property) { create(:product_property, property: property, product: product) }- let(:product_property_2) { create(:product_property, property: property, product: product_2, value: 'Test Test') }-- before do- product_property.update_column(:filter_param, nil)- product_property.update_column(:value, 'some_value')- end-- context 'filterable property' do- it { expect { property.update(filterable: true) }.to change { product_property.reload.filter_param }.from(nil) }- it { expect { property.update(filterable: true) }.not_to change { product_property_2.reload.updated_at } }- end-- context 'not-filterable property' do- it { expect { property.update(name: 'test') }.not_to change { product_property.reload.filter_param }.from(nil) }- end- end-- describe '#after_touch callback' do- let!(:product_property) { create(:product_property) }-- it 'touches the product' do- expect { product_property.property.touch }.to change { product_property.product.reload.updated_at }- end- end-- describe '#after_update callback' do- let!(:product_property) { create(:product_property) }-- context 'with DEPENDENCY_UPDATE_FIELDS' do- it 'touches the product' do- expect { product_property.property.update(name: 'test') }.to change { product_property.product.reload.updated_at }- end- end-- context 'without DEPENDENCY_UPDATE_FIELDS' do- it 'does not touch the product' do- expect { product_property.property.update(updated_at: Time.now) }.not_to change { product_property.product.reload.updated_at }- end- end- end-- describe '#kind_to_metafield_type' do- let(:property) { create(:property, kind: 'short_text') }-- it 'returns the correct metafield type' do- expect(property.kind_to_metafield_type).to eq('Spree::Metafields::ShortText')- end-- context 'when the property kind is long_text' do- let(:property) { create(:property, kind: 'long_text') }-- it 'returns the correct metafield type' do- expect(property.kind_to_metafield_type).to eq('Spree::Metafields::LongText')- end- end-- context 'when the property kind is number' do- let(:property) { create(:property, kind: 'number') }-- it 'returns the correct metafield type' do- expect(property.kind_to_metafield_type).to eq('Spree::Metafields::Number')- end- end-- context 'when the property kind is rich_text' do- let(:property) { create(:property, kind: 'rich_text') }-- it 'returns the correct metafield type' do- expect(property.kind_to_metafield_type).to eq('Spree::Metafields::RichText')- end- end- end-enddiff --git a/spree/core/spec/models/spree/store_spec.rb b/spree/core/spec/models/spree/store_spec.rbindex 14ffebbfa3..55dafd69f0 100644--- a/spree/core/spec/models/spree/store_spec.rb+++ b/spree/core/spec/models/spree/store_spec.rb@@ -14,13 +14,6 @@ describe Spree::Store, type: :model, without_global_store: true doit { expect(subject.products).to eq([product]) }- describe '#product_properties' do- let!(:product_property) { create(:product_property, product: product) }- let!(:product_property_2) { create(:product_property, product: product_2) }-- it { expect(subject.product_properties).to eq([product_property]) }- end-describe '#variants' dolet!(:variant) { create(:variant, product: product) }let!(:variant_2) { create(:variant, product: product_2) }diff --git a/spree/core/spec/presenters/spree/filters/properties_presenter_spec.rb b/spree/core/spec/presenters/spree/filters/properties_presenter_spec.rbdeleted file mode 100644index c95230ae0c..0000000000--- a/spree/core/spec/presenters/spree/filters/properties_presenter_spec.rb+++ /dev/null@@ -1,34 +0,0 @@-require 'spec_helper'--module Spree- RSpec.describe Filters::PropertiesPresenter do- let(:properties) { described_class.new(product_properties_scope: ProductProperty.where(id: product_properties)) }- let(:product_properties) { [alpha_brand, beta_brand, wilson_manufacturer] }-- let(:brand) { create(:property, :brand, :filterable) }- let(:alpha_brand) { create(:product_property, property: brand, value: 'Alpha') }- let(:beta_brand) { create(:product_property, property: brand, value: 'Beta') }-- let(:manufacturer) { create(:property, :manufacturer, :filterable) }- let(:wilson_manufacturer) { create(:product_property, property: manufacturer, value: 'Wilson') }-- before do- create(:product_property, property: brand, value: 'Gamma')- create(:product_property, property: manufacturer, value: 'Jerseys')- end-- describe '#to_a' do- subject(:filterable_properties) { properties.to_a }-- it 'returns filterable Product Properties' do- aggregate_failures 'filterable product properties' do- brand_property = filterable_properties.find { |property| property.name == brand.name }- expect(brand_property.product_properties).to contain_exactly(alpha_brand, beta_brand)-- manufacturer_property = filterable_properties.find { |property| property.name == manufacturer.name }- expect(manufacturer_property.product_properties).to contain_exactly(wilson_manufacturer)- end- end- end- end-enddiff --git a/spree/core/spec/presenters/spree/filters/property_presenter_spec.rb b/spree/core/spec/presenters/spree/filters/property_presenter_spec.rbdeleted file mode 100644index 0600e24efa..0000000000--- a/spree/core/spec/presenters/spree/filters/property_presenter_spec.rb+++ /dev/null@@ -1,24 +0,0 @@-require 'spec_helper'--module Spree- RSpec.describe Filters::PropertyPresenter do- let(:property) { described_class.new(property: brand, product_properties: product_properties) }- let(:product_properties) { [alpha_brand, beta_brand] }-- let(:brand) { create(:property, :brand, :filterable) }- let(:alpha_brand) { create(:product_property, property: brand, value: 'Alpha') }- let(:beta_brand) { create(:product_property, property: brand, value: 'Beta') }-- before do- create(:product_property, property: brand, value: 'Gamma')- end-- describe '#uniq_values' do- subject(:uniq_values) { property.uniq_values }-- it 'returns unique Product Properties values for a given list of Product Properties' do- expect(uniq_values).to match_array([['alpha', 'Alpha'], ['beta', 'Beta']])- end- end- end-enddiff --git a/spree/core/spec/services/spree/products/duplicator_spec.rb b/spree/core/spec/services/spree/products/duplicator_spec.rbindex ea9bde3d34..6d836050dd 100644--- a/spree/core/spec/services/spree/products/duplicator_spec.rb+++ b/spree/core/spec/services/spree/products/duplicator_spec.rb@@ -5,7 +5,6 @@ RSpec.describe Spree::Products::Duplicator dolet(:store) { @default_store }- let!(:product_property) { create(:product_property, product: product) }let!(:product) { create(:product, stores: [store], tag_list: ['tag1', 'tag2'], status: :active) }let(:filepath) { File.expand_path('../../../fixtures/thinking-cat.jpg', __dir__) }@@ -69,11 +68,6 @@ RSpec.describe Spree::Products::Duplicator doexpect(new_product.sku).to include 'COPY OF SKU'end- it 'copies the properties' do- expect(new_product.product_properties.count).to eq 1- expect(new_product.product_properties.first.property.name).to eql product_property.property.name- end-it 'copies tags' doexpect(new_product.tag_list).to match_array(['tag1', 'tag2'])enddiff --git a/spree/core/spec/services/spree/products/prepare_nested_attributes_spec.rb b/spree/core/spec/services/spree/products/prepare_nested_attributes_spec.rbindex 4977fcb11b..d693afd122 100644--- a/spree/core/spec/services/spree/products/prepare_nested_attributes_spec.rb+++ b/spree/core/spec/services/spree/products/prepare_nested_attributes_spec.rb@@ -149,44 +149,6 @@ RSpec.describe Spree::Products::PrepareNestedAttributes doendend- describe 'product_properties_attributes handling' do- context 'when product property value is blank' do- let(:product_property) { create(:product_property, product: product) }- let(:raw_params) do- {- product_properties_attributes: {- '0' => {- id: product_property.id,- value: ''- }- }- }- end-- it 'marks the product property for destruction' do- expect(prepared_params[:product_properties_attributes]['0']['_destroy']).to eq('1')- end- end-- context 'when product property value is present' do- let(:product_property) { create(:product_property, product: product) }- let(:raw_params) do- {- product_properties_attributes: {- '0' => {- id: product_property.id,- value: 'New Value'- }- }- }- end-- it 'does not mark the product property for destruction' do- expect(prepared_params[:product_properties_attributes]['0']['_destroy']).to be_nil- end- end- end-describe 'prices_attributes handling' dolet(:variant) { product.master }