Class: Edi::Wayfair::VariantGrouping
- Inherits:
-
Object
- Object
- Edi::Wayfair::VariantGrouping
- Defined in:
- app/services/edi/wayfair/variant_grouping.rb
Overview
Wayfair Product Addition variant-grouping directive: which group a proposed
product belongs to and which option axes distinguish its variants.
Phase 0 of the variant-grouping unification
(doc/tasks/202607051428_VARIANT_GROUPING_UNIFICATION.md): instead of
submitting every product as Not Variant and asking Wayfair Merchandising to
merge the listings after the fact (Consolidate Products tickets), new
products are born grouped — variantType Primary/Non-Primary, a shared
groupReferenceId per family, and option category/value pairs derived from
the item's VariantGroup axes (the canonical variant-axis source; see
VariantGroup#to_wayfair_variant_grouping).
Constant Summary collapse
- TOKEN_CATEGORY_MAP =
VariantGroup
axis_tokens→ Wayfair option-category names.coverage
maps to Size because floor-heating SKU ladders are merchandised by area. { 'voltage' => 'Voltage', 'size' => 'Size', 'coverage' => 'Size' }.freeze
- ORDINALS =
Wayfair supports up to three option categories per group.
%w[One Two Three].freeze
Instance Attribute Summary collapse
-
#categories ⇒ Hash{String=>String}
readonly
Ordered option-category => this product's value.
-
#group_reference_id ⇒ String
readonly
Shared id tying the family's products into one group.
-
#variant_type ⇒ String
readonly
PrimaryorNon-Primary.
Instance Method Summary collapse
-
#initialize(group_reference_id:, categories:, primary: false) ⇒ VariantGrouping
constructor
A new instance of VariantGrouping.
-
#to_attributes ⇒ Array<Hash>
The namespaced
variantGrouping::*attributes for a submitV2 proposed product.
Constructor Details
#initialize(group_reference_id:, categories:, primary: false) ⇒ VariantGrouping
Returns a new instance of VariantGrouping.
37 38 39 40 41 42 43 44 |
# File 'app/services/edi/wayfair/variant_grouping.rb', line 37 def initialize(group_reference_id:, categories:, primary: false) @group_reference_id = group_reference_id.to_s @categories = categories.to_h .transform_keys(&:to_s).transform_values(&:to_s) .reject { |key, value| key.blank? || value.blank? } .first(ORDINALS.size).to_h @variant_type = primary ? 'Primary' : 'Non-Primary' end |
Instance Attribute Details
#categories ⇒ Hash{String=>String} (readonly)
Returns ordered option-category => this product's value.
32 33 34 |
# File 'app/services/edi/wayfair/variant_grouping.rb', line 32 def categories @categories end |
#group_reference_id ⇒ String (readonly)
Returns shared id tying the family's products into one group.
28 29 30 |
# File 'app/services/edi/wayfair/variant_grouping.rb', line 28 def group_reference_id @group_reference_id end |
#variant_type ⇒ String (readonly)
Returns Primary or Non-Primary.
30 31 32 |
# File 'app/services/edi/wayfair/variant_grouping.rb', line 30 def variant_type @variant_type end |
Instance Method Details
#to_attributes ⇒ Array<Hash>
Returns the namespaced variantGrouping::* attributes for a
submitV2 proposed product.
48 49 50 51 52 53 54 55 56 57 |
# File 'app/services/edi/wayfair/variant_grouping.rb', line 48 def to_attributes # Only these two are valid submitV2 inputs — Wayfair derives the option # axes from class standards, and no category attribute id exists (probe # details in doc/tasks/202607051428_VARIANT_GROUPING_UNIFICATION.md). # #categories feeds only our side (axis derivation, future adapters). [ { attributeId: 'variantGrouping::variantType', value: variant_type }, { attributeId: 'variantGrouping::groupReferenceId', value: group_reference_id } ] end |