I am trying to download products from a Magento store into my Rails database using the "magento-rb" library located here: https://github.com/joelvh/magento-rb
I've tried the following code:
xml_api = Magento::XmlApi.new "http://website.com/api/xmlrpc/", "myusername", "mypassword", :debug => true
products = xml_api.call("catalog_product.list")
products.each do |p|
@exists = Product.where("sku = ?",p["sku"])
if @exists
@product = Product.find_by_sku(p["sku"])
else
@product = Product.new
end
@product.sku = p["sku"]
@product.name = p["name"]
@product.mage_product_id = p["product_id"]
@product.save
end
Unfortunately I am getting this error:
NoMethodError in Admin::ProductsController#test
undefined method `sku=' for nil:NilClass
I should note that I have confirmed that "sku" is indeed an attribute to the Product model, and I have also tried resetting the server. Any ideas?