<commit_before>Spree::StockLocation.class_eval do

  belongs_to :supplier
  attr_accessible :supplier_id

  scope :with_supplier, ->(supplier) { where(supplier_id: supplier) }

  # Wrapper for creating a new stock item respecting the backorderable config and supplier
  durably_decorate :propagate_variant, mode: 'soft', sha: 'f35b0d8a811311d4886d53024a9aa34e3aa5f8cb' do |variant|
    if self.supplier_id.nil? or self.supplier_id == variant.product.supplier_id
      self.stock_items.create!(variant: variant, backorderable: self.backorderable_default)
    else
      # Never allow alternate suppliers locations to take backorders for a product.<commit_msg>Fix for when products deleted.<commit_after>Spree::StockLocation.class_eval do

  belongs_to :supplier
  attr_accessible :supplier_id

  scope :with_supplier, ->(supplier) { where(supplier_id: supplier) }

  # Wrapper for creating a new stock item respecting the backorderable config and supplier
  durably_decorate :propagate_variant, mode: 'soft', sha: 'f35b0d8a811311d4886d53024a9aa34e3aa5f8cb' do |variant|
    if self.supplier_id.nil? or self.supplier_id == variant.product.try(:supplier_id)
      self.stock_items.create!(variant: variant, backorderable: self.backorderable_default)
    else
      # Never allow alternate suppliers locations to take backorders for a product.
{'fraction_non_alphanumeric': 0.07766990291262135, 'fraction_numerical': 0.037341299477221805, 'mean_word_length': 5.4423076923076925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7381520', 'n_tokens_mistral': 453, 'n_tokens_neox': 422, 'n_words': 109}