Paul, thanks for the info. That gist looks great. At least from my
newb perspective.
Can you give me an idea what your data looks like in the csv? I think
I have a reasonable idea how your doing the import but I don't get how
the csv looks. Do you have 1 csv with all the product info? I have
two levels of taxons, and this is the last item on the list for a
site.
thanks for so much help.
On Mar 3, 2:29 am, Paul Callaghan <p...@railsdog.com> wrote:
> Or seehttp://gist.github.com/130061, lines 164-174, for a more general
> solution
>
> This splits a line "foo, bar, wibble" and puts the product in taxon "wibble"
> which has parent "bar" and grandparent "foo", creating any missing taxons
> that are required.
>
> Paul
>
> On Wed, Mar 3, 2010 at 8:25 AM, Brian Quinn <br...@railsdog.com> wrote:
> > So the Taxon's already exist you just want to associated them with the new
> > product?
>
> > If so then after product.save(false) do:
>
> > product.taxons << Taxon.find(1234)
>
> > or
>
> > product.taxons << Taxon.find_by_name("My Taxon")
>
> > On 3 March 2010 00:29, ravenna <t...@ravennainteractive.com> wrote:
>
> >> Ok I know why that didn't work. There is no creation of a taxon.
>
> >> So here is the part that is instantiating a new product:
> >> if row[0].nil?
> >> # Adding new product
> >> puts "Adding new product: #{row[1]}"
> >> product = Product.new()
>
> >> n += 1
>
> >> The question is, with the db, taxons and products seem to be related
> >> through a products_taxons table. Because thats not a new object I
> >> would just want to input a new row in the products_taxons table.
>
> >> What would I add to the method and what would I then add to the rows
> >> list:
> >> product.name = row[2]
> >> product.available_on = Time.now
> >> product.description = row[3]
> >> # product.permalink = row[6].to_s
> >> product.sku = row[4]
> >> product.width = row[5]
> >> product.vendor_sku = row[7]
> >> product.master_price = row[8]#.to_d
> >> product.save(false)
> >> end
>
> >> any ideas? thanks
>
> >> On Feb 26, 11:14 am, ravenna <t...@ravennainteractive.com> wrote:
> >> > Brian,
>
> >> > is it possible to add something to this that allows me to set the
> >> > taxons for a product?
>
> >> > product.name = row[2]
> >> > product.available_on = Time.now
> >> > product.description = row[3]
> >> > # product.permalink = row[6].to_s
> >> > product.sku = row[4]
> >> > product.width = row[5]
> >> > product.vendor_sku = row[7]
> >> > product.master_price = row[8]#.to_d
> >> > taxon.name = row[9]
> >> > product.save(false)
>
> >> > Tried the above code but it bails: undefined local variable or method
> >> > `taxon' for main:Object
>
> >> > Or do I need to have a 2ndcsvthat adds product id's to the taxons
> >> > table... If so how would that look?
>
> >> > thanks so much for the help.
>
> >> > On Feb 23, 5:16 pm, ravenna <t...@ravennainteractive.com> wrote:
>
> >> > > Brian,
>
> >> > > thanks I got it working for a single entry but I am having trouble
> >> > > with multiples...
>
> >> > > If I have:
> >> > > ,,ALTAI,90% wool 10% cashmere (melange),,,altai,,,,,,A3668RS,385
> >> > > ,,ALTAI21,90% wool 10% cashmere
> >> > > (melange)test,,,altai2,,,,,,A3668RS2,3852
>
> >> > > in mycsv, as test data. I think I am ending the row incorrectly.
> >> > > any thoughts?
>
> >> > > thanks
>
> >> > > On Feb 23, 10:17 am, Brian Quinn <br...@railsdog.com> wrote:
>
> >> > > > I don't think that's an actual locale issue, it's just that you've
> >> got an
> >> > > > invalid product object.
>
> >> > > > Try changing line 55 from:
>
> >> > > > product.save!
>
> >> > > > to
>
> >> > > > product.save(false)
>
> >> > > > Which will save it without validation, or u check the validators in
> >> > > > product.rb and see what ur missing.
>
> >> > > > On 23 February 2010 17:23,ravenna<t...@ravennainteractive.com>
> >> wrote:
>
> >> > > > > Thanks for the info Brian, that helps me get it a little better.
>
> >> > > > > I fixed the id related issue on my own. Now I am getting a
> >> > > > > translation issue.
>
> >> > > > > ** Execute spree:import_products
> >> > > > > Adding new product: ALTAI
> >> > > > > rake aborted!
> >> > > > > translation missing: en-US, activerecord, errors, messages,
> >> > > > > record_invalid
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > validations.rb:1090:in `save_without_dirty!'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > dirty.rb:87:in `save_without_transactions!'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > transactions.rb:200:in `save!'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > connection_adapters/abstract/database_statements.rb:136:in
> >> > > > > `transaction'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > transactions.rb:182:in `transaction'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > transactions.rb:200:in `save!'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > transactions.rb:208:in `rollback_active_record_state!'
>
> >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
> >> > > > > transactions.rb:200:in `save!'
> >> > > > > /Users/tjs/Sites/dshome/lib/tasks/import.rake:36
> >> > > > > /Users/tjs/.gem/ruby/1.8/gems/fastercsv-1.5.0/lib/faster_csv.rb:
> >> > > > > 1521:in `each'
> >> > > > > /Users/tjs/.gem/ruby/1.8/gems/fastercsv-1.5.0/lib/faster_csv.rb:
> >> > > > > 1024:in `foreach'
> >> > > > > /Users/tjs/.gem/ruby/1.8/gems/fastercsv-1.5.0/lib/faster_csv.rb:
> >> > > > > 1198:in `open'
> >> > > > > /Users/tjs/.gem/ruby/1.8/gems/fastercsv-1.5.0/lib/faster_csv.rb:
> >> > > > > 1023:in `foreach'
> >> > > > > /Users/tjs/Sites/dshome/lib/tasks/import.rake:10
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
> >> `call'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
> >> > > > > `execute'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
> >> `each'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
> >> > > > > `execute'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
> >> > > > > `invoke_with_call_chain'
> >> > > > > /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
> >> > > > > `invoke_with_call_chain'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
> >> > > > > `invoke'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
> >> > > > > `invoke_task'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> >> > > > > `top_level'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> >> > > > > `each'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> >> > > > > `top_level'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> >> > > > > `standard_exception_handling'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
> >> > > > > `top_level'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
> >> `run'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> >> > > > > `standard_exception_handling'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
> >> `run'
> >> > > > > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
> >> > > > > /usr/local/bin/rake:19:in `load'
> >> > > > > /usr/local/bin/rake:19
>
> >> > > > > I don't have translation issues in the normal products that are
> >> > > > > already in the site. Do I need to add something to the
> >> translations
> >> > > > > yml file?
>
> >> > > > > --
> >> > > > > You received this message because you are subscribed to the Google
> >> Groups
> >> > > > > "Spree" group.
> >> > > > > To post to this group, send email to spree-user@googlegroups.com.
> >> > > > > To unsubscribe from this group, send email to
> >> > > > > spree-user+unsubscribe@googlegroups.com<spree-user%2Bunsubscribe@googlegroups.com>
> >> <spree-user%2Bunsubscribe@googlegroups.com<spree-user%252Bunsubscribe@googlegroups.com>
>
> >> > > > > .
> >> > > > > For more options, visit this group at
> >> > > > >http://groups.google.com/group/spree-user?hl=en.
>
> >> > > > --
> >> > > > Brian Quinn
>
> >> > > > -------------------------------------------
> >> > > > Rails Dog LLC
> >> > > > 2 Wisconsin Circle, Suite 700
> >> > > > Chevy Chase, MD 20815
> >> > > > voice: (301)560-2000
> >> > > > -------------------------------------------
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Spree" group.
> >> To post to this group, send email to spree-user@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> spree-user+unsubscribe@googlegroups.com<spree-user%2Bunsubscribe@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/spree-user?hl=en.
>
> > --
> > Brian Quinn
>
> > -------------------------------------------
> > Rails Dog LLC
> > 2 Wisconsin Circle, Suite 700
> > Chevy Chase, MD 20815
> > voice: (301)560-2000
> > -------------------------------------------
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Spree" group.
> > To post to this group, send email to spree-user@googlegroups.com.
> > To unsubscribe from this group, send email to
> > spree-user+unsubscribe@googlegroups.com<spree-user%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/spree-user?hl=en.
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
No comments:
Post a Comment