GithubHelp home page GithubHelp logo

Comments (9)

autotelik avatar autotelik commented on August 10, 2024

Spree added a whole new stock keeping layer to Spree 2

The old count_on_hand is no longer on Variant. Have you tried using the master branch ... I have been working to get full 2 support in master ..

If you still have issues, see from line 138 of https://github.com/autotelik/datashift_spree/blob/master/lib/loaders/spree/product_loader.rb - v.stock_items.first.count_on_hand

from datashift_spree.

redglory avatar redglory commented on August 10, 2024

I'm running from master (git assignment).

This is a row form my .xls:

sku | name |    description | avaliable_on  | cost_price |  price   | shipping_category | tax_category |    taxons |    taxons |    taxons |    taxons |    product_properties |    variants    | stock_location_name | stock_items
3218 |  Conjunto Gorro e Luvas |    Conjunto Gorro e Luvas  | 2015-02-12    | 6,28 |    13,82   | CTT - Correio Normal < 2kg    | IVA   | Secções>Bebé Menino    | Marcas>Tuc Tuc |  Categorias>Gorros e Bonés |        Composição:100% Algodão  | newborn-clothes-size:0M;color:branco  | casa_susana   | count_on_hand:1

My log states:

#<ActiveRecord::RecordInvalid: Validation failed: Stock location can't be blank, Variant can't be blank>
Cannot assign [#<Spree::StockItem id: nil, stock_location_id: nil, variant_id: nil, count_on_hand: 0, created_at: nil, updated_at: nil, backorderable: false, deleted_at: nil>] (Array) to has_many association [stock_items] 

I'm trying to pass a column as "stock_location_name" before sotck_items one...

Will look into this code and thank you for your support :)

from datashift_spree.

autotelik avatar autotelik commented on August 10, 2024

To manage stock you need at least one Stock Location defined in your store. IF yuo cleared out the defautl seeds etc you may not have the default ... you can add one via the admin GUI ... .. see https://guides.spreecommerce.com/user/configuring_inventory.html

I did come across another potential call you might try..adjust_count_on_hand :

variant.stock_items.first.adjust_count_on_hand(quantity)

from datashift_spree.

redglory avatar redglory commented on August 10, 2024

I have 2 stock locations defined on my DB. I tried to select one in my .xls with column "stock_location" and value "name:casa_susana" to no avail.

I would have to replace product_loader.rb to accomplish that right? (variant.stock_items.first.adjust_count_on_hand(quantity))

from datashift_spree.

autotelik avatar autotelik commented on August 10, 2024

yes something like ... inherit from product_loader

implement ... your own def process(method_detail, value)
which just fixes for count on hand otherwise call super

if(current_value && (current_method_detail.operator?('count_on_hand') || current_method_detail.operator?('on_hand')) )

 # NEW IMPLEMENTATION THAT WORKS FOR STOCK

else
super( file_name, opts )
end

from datashift_spree.

redglory avatar redglory commented on August 10, 2024

Forking your project and gonna try this.

Thanks for the pointers :)

from datashift_spree.

redglory avatar redglory commented on August 10, 2024

I've forked datashift_spree and made some changes so that we can load stock with Spree version >= 2.2.

already tested. sure it needs some code cleanup but it works, at least for me

https://github.com/redglory/datashift_spree/blob/master/lib/loaders/spree/product_loader.rb

Please check :)

from datashift_spree.

autotelik avatar autotelik commented on August 10, 2024

Hi .. thanks so much for contributing .. please submit a pull request, will be easier to visualize diffs and I will merge into main gem

cheers
tom

from datashift_spree.

redglory avatar redglory commented on August 10, 2024

Hey sure thing.

Not at home right nos but will pull request lateral at night.

Cheers

EDIT: #36

from datashift_spree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.