Skip to content
This repository was archived by the owner on Apr 27, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/shopify_transporter/exporters/magento/product_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ def with_attributes(product)
case product[:type]
when 'simple'
product_with_base_attributes
.merge(categories: categories_for(product_with_base_attributes))
.merge(inventory_quantity: inventory_quantity_for(product[:product_id]))
.merge(variant_option_values(product_with_base_attributes))
when 'configurable'
product_with_base_attributes
.merge(categories: categories_for(product_with_base_attributes))
.merge(configurable_product_options(product_with_base_attributes))
else
product_with_base_attributes
Expand Down Expand Up @@ -117,6 +119,26 @@ def inventory_quantity_for(product_id)
.body[:catalog_inventory_stock_item_list_response][:result][:item][:qty].to_i
end

def categories_for(product)
categories = []

if product[:categories][:item]
if product[:categories][:item].is_a? Array
product[:categories][:item].each do |category_id|
categories.push(@client
.call(:catalog_category_info, category_id: category_id.to_i )
.body[:catalog_category_info_response][:info])
end
else
categories.push(@client
.call(:catalog_category_info, category_id: product[:categories][:item].to_i )
.body[:catalog_category_info_response][:info])
end
end

return categories
end

def images_attribute(product_id)
@client
.call(:catalog_product_attribute_media_list, product: product_id.to_i)
Expand Down