gemgento 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/README.md +9 -0
- data/Rakefile +21 -0
- data/app/adapters/gemgento/magento/address_adapter.rb +37 -0
- data/app/adapters/gemgento/magento/customer_adapter.rb +24 -0
- data/app/adapters/gemgento/magento/line_item_adapter.rb +41 -0
- data/app/adapters/gemgento/magento/order_adapter.rb +97 -0
- data/app/adapters/gemgento/magento/order_status_adapter.rb +24 -0
- data/app/adapters/gemgento/magento/payment_adapter.rb +38 -0
- data/app/adapters/gemgento/magento/product_adapater.rb +24 -0
- data/app/adapters/gemgento/magento/quote_adapter.rb +17 -0
- data/app/adapters/gemgento/magento/shipment_adapter.rb +74 -0
- data/app/adapters/gemgento/magento/shipment_item_adapter.rb +39 -0
- data/app/adapters/gemgento/magento/shipment_track_adapter.rb +31 -0
- data/app/adapters/gemgento/magento_adapter.rb +17 -0
- data/app/assets/fonts/FuturaStd-Bold.otf +0 -0
- data/app/assets/fonts/FuturaStd-Book.otf +0 -0
- data/app/assets/fonts/FuturaStd-Light.otf +0 -0
- data/app/assets/fonts/FuturaStd-Medium.otf +0 -0
- data/app/assets/fonts/Verlag-Black.otf +0 -0
- data/app/assets/fonts/Verlag-BlackItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Bold.otf +0 -0
- data/app/assets/fonts/Verlag-BoldItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Book.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic-2.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic-3.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Light.otf +0 -0
- data/app/assets/fonts/Verlag-LightItalic.otf +0 -0
- data/app/assets/fonts/Verlag-XLight.otf +0 -0
- data/app/assets/fonts/Verlag-XLightItalic.otf +0 -0
- data/app/assets/images/about_store.jpg +0 -0
- data/app/assets/images/gemgento-icon-bolt.png +0 -0
- data/app/assets/javascripts/gemgento/active_admin.js.coffee +42 -0
- data/app/assets/javascripts/gemgento/checkout/address.coffee +23 -0
- data/app/assets/javascripts/gemgento/gemgento.js +1 -0
- data/app/assets/javascripts/gemgento/global.js.coffee +31 -0
- data/app/assets/stylesheets/gemgento/active_admin.css.scss +549 -0
- data/app/assets/stylesheets/gemgento/default-views/_address.scss +11 -0
- data/app/assets/stylesheets/gemgento/default-views/_category.scss +54 -0
- data/app/assets/stylesheets/gemgento/default-views/_checkout.scss +28 -0
- data/app/assets/stylesheets/gemgento/default-views/_footer.scss +13 -0
- data/app/assets/stylesheets/gemgento/default-views/_form.scss +127 -0
- data/app/assets/stylesheets/gemgento/default-views/_header.scss +32 -0
- data/app/assets/stylesheets/gemgento/default-views/_layout.css.scss +157 -0
- data/app/assets/stylesheets/gemgento/default-views/_pages.css.scss +83 -0
- data/app/assets/stylesheets/gemgento/default-views/_product.scss +57 -0
- data/app/assets/stylesheets/gemgento/default-views/_shopping_bag.scss +87 -0
- data/app/assets/stylesheets/gemgento/default-views/_subheader.css.scss +30 -0
- data/app/assets/stylesheets/gemgento/default-views/application.css.scss +1 -0
- data/app/controllers/concerns/gemgento/api/v1/base.rb +15 -0
- data/app/controllers/concerns/gemgento/api/v1/product_filters.rb +33 -0
- data/app/controllers/gemgento/addresses_controller.rb +14 -0
- data/app/controllers/gemgento/api/v1/categories_controller.rb +13 -0
- data/app/controllers/gemgento/api/v1/products_controller.rb +23 -0
- data/app/controllers/gemgento/api/v1/search_controller.rb +14 -0
- data/app/controllers/gemgento/application_controller.rb +5 -0
- data/app/controllers/gemgento/cart_controller.rb +99 -0
- data/app/controllers/gemgento/categories_controller.rb +37 -0
- data/app/controllers/gemgento/checkout/address_controller.rb +48 -0
- data/app/controllers/gemgento/checkout/confirm_controller.rb +72 -0
- data/app/controllers/gemgento/checkout/coupons_controller.rb +42 -0
- data/app/controllers/gemgento/checkout/gift_card_controller.rb +39 -0
- data/app/controllers/gemgento/checkout/gift_controller.rb +32 -0
- data/app/controllers/gemgento/checkout/login_controller.rb +123 -0
- data/app/controllers/gemgento/checkout/payment_controller.rb +70 -0
- data/app/controllers/gemgento/checkout/paypal_controller.rb +23 -0
- data/app/controllers/gemgento/checkout/shipping_controller.rb +46 -0
- data/app/controllers/gemgento/checkout/shipping_payment_controller.rb +58 -0
- data/app/controllers/gemgento/checkout/thank_you_controller.rb +45 -0
- data/app/controllers/gemgento/checkout_controller.rb +120 -0
- data/app/controllers/gemgento/countries_controller.rb +17 -0
- data/app/controllers/gemgento/errors_controller.rb +7 -0
- data/app/controllers/gemgento/footer_items_controller.rb +16 -0
- data/app/controllers/gemgento/home_controller.rb +7 -0
- data/app/controllers/gemgento/magento/addresses_controller.rb +61 -0
- data/app/controllers/gemgento/magento/base_controller.rb +18 -0
- data/app/controllers/gemgento/magento/categories_controller.rb +103 -0
- data/app/controllers/gemgento/magento/email/sales/credit_memos_controller.rb +21 -0
- data/app/controllers/gemgento/magento/email/sales/invoices_controller.rb +21 -0
- data/app/controllers/gemgento/magento/email/sales/orders_controller.rb +20 -0
- data/app/controllers/gemgento/magento/email/sales/shipments_controller.rb +25 -0
- data/app/controllers/gemgento/magento/emails_controller.rb +11 -0
- data/app/controllers/gemgento/magento/inventory_controller.rb +30 -0
- data/app/controllers/gemgento/magento/orders_controller.rb +12 -0
- data/app/controllers/gemgento/magento/price_rules_controller.rb +22 -0
- data/app/controllers/gemgento/magento/product_attribute_sets_controller.rb +37 -0
- data/app/controllers/gemgento/magento/product_attributes_controller.rb +70 -0
- data/app/controllers/gemgento/magento/products_controller.rb +240 -0
- data/app/controllers/gemgento/magento/recurring_profiles_controller.rb +42 -0
- data/app/controllers/gemgento/magento/stores_controller.rb +21 -0
- data/app/controllers/gemgento/magento/user_groups_controller.rb +23 -0
- data/app/controllers/gemgento/magento/users_controller.rb +63 -0
- data/app/controllers/gemgento/order_export_controller.rb +21 -0
- data/app/controllers/gemgento/orders_controller.rb +12 -0
- data/app/controllers/gemgento/products_controller.rb +12 -0
- data/app/controllers/gemgento/regions_controller.rb +18 -0
- data/app/controllers/gemgento/search_controller.rb +16 -0
- data/app/controllers/gemgento/shipments_controller.rb +5 -0
- data/app/controllers/gemgento/stock_notifications_controller.rb +22 -0
- data/app/controllers/gemgento/subscribers_controller.rb +35 -0
- data/app/controllers/gemgento/sync_controller.rb +50 -0
- data/app/controllers/gemgento/user/addresses_controller.rb +79 -0
- data/app/controllers/gemgento/user/base_controller.rb +14 -0
- data/app/controllers/gemgento/user/home_controller.rb +9 -0
- data/app/controllers/gemgento/user/orders_controller.rb +17 -0
- data/app/controllers/gemgento/user/passwords_controller.rb +18 -0
- data/app/controllers/gemgento/user/recurring_profiles_controller.rb +31 -0
- data/app/controllers/gemgento/user/registration_session_controller.rb +103 -0
- data/app/controllers/gemgento/user/registrations_controller.rb +28 -0
- data/app/controllers/gemgento/user/saved_credit_cards_controller.rb +56 -0
- data/app/controllers/gemgento/user/sessions_controller.rb +50 -0
- data/app/controllers/gemgento/user/wishlist_items_controller.rb +55 -0
- data/app/controllers/gemgento/users_controller.rb +36 -0
- data/app/helpers/gemgento/application_helper.rb +125 -0
- data/app/helpers/gemgento/categories_helper.rb +39 -0
- data/app/helpers/gemgento/checkout/payment_helper.rb +5 -0
- data/app/helpers/gemgento/products_helper.rb +23 -0
- data/app/jobs/gemgento/import_job.rb +12 -0
- data/app/mailers/gemgento/sales_mailer.rb +80 -0
- data/app/models/admin_user.rb +7 -0
- data/app/models/concerns/gemgento/product_touches.rb +26 -0
- data/app/models/gemgento.rb +5 -0
- data/app/models/gemgento/adapter/sellect/customer.rb +34 -0
- data/app/models/gemgento/adapter/sellect/order.rb +378 -0
- data/app/models/gemgento/adapter/sellect/product.rb +250 -0
- data/app/models/gemgento/adapter/sellect_adapter.rb +16 -0
- data/app/models/gemgento/adapter/shopify/address.rb +40 -0
- data/app/models/gemgento/adapter/shopify/category.rb +51 -0
- data/app/models/gemgento/adapter/shopify/customer.rb +66 -0
- data/app/models/gemgento/adapter/shopify/order.rb +334 -0
- data/app/models/gemgento/adapter/shopify/product.rb +377 -0
- data/app/models/gemgento/adapter/shopify/product_category_position.rb +58 -0
- data/app/models/gemgento/adapter/shopify_adapter.rb +63 -0
- data/app/models/gemgento/address.rb +206 -0
- data/app/models/gemgento/api_job.rb +68 -0
- data/app/models/gemgento/asset.rb +185 -0
- data/app/models/gemgento/asset_file.rb +57 -0
- data/app/models/gemgento/asset_type.rb +8 -0
- data/app/models/gemgento/bundle.rb +5 -0
- data/app/models/gemgento/bundle/item.rb +17 -0
- data/app/models/gemgento/bundle/option.rb +20 -0
- data/app/models/gemgento/category.rb +235 -0
- data/app/models/gemgento/country.rb +21 -0
- data/app/models/gemgento/gift_message.rb +8 -0
- data/app/models/gemgento/image_import.rb +141 -0
- data/app/models/gemgento/import.rb +125 -0
- data/app/models/gemgento/inventory.rb +60 -0
- data/app/models/gemgento/inventory_import.rb +51 -0
- data/app/models/gemgento/line_item.rb +142 -0
- data/app/models/gemgento/line_item_option.rb +10 -0
- data/app/models/gemgento/magento_db.rb +35 -0
- data/app/models/gemgento/magento_response.rb +10 -0
- data/app/models/gemgento/order.rb +56 -0
- data/app/models/gemgento/order_status.rb +7 -0
- data/app/models/gemgento/payment.rb +50 -0
- data/app/models/gemgento/price_rule.rb +258 -0
- data/app/models/gemgento/price_tier.rb +36 -0
- data/app/models/gemgento/product.rb +607 -0
- data/app/models/gemgento/product_attribute.rb +48 -0
- data/app/models/gemgento/product_attribute_option.rb +39 -0
- data/app/models/gemgento/product_attribute_set.rb +22 -0
- data/app/models/gemgento/product_attribute_value.rb +26 -0
- data/app/models/gemgento/product_category.rb +34 -0
- data/app/models/gemgento/product_import.rb +359 -0
- data/app/models/gemgento/quote.rb +586 -0
- data/app/models/gemgento/recurring_profile.rb +28 -0
- data/app/models/gemgento/region.rb +14 -0
- data/app/models/gemgento/relation.rb +10 -0
- data/app/models/gemgento/relation_type.rb +7 -0
- data/app/models/gemgento/saved_credit_card.rb +45 -0
- data/app/models/gemgento/search.rb +14 -0
- data/app/models/gemgento/session.rb +49 -0
- data/app/models/gemgento/shipment.rb +38 -0
- data/app/models/gemgento/shipment_comment.rb +19 -0
- data/app/models/gemgento/shipment_item.rb +11 -0
- data/app/models/gemgento/shipment_track.rb +21 -0
- data/app/models/gemgento/stock_notification.rb +17 -0
- data/app/models/gemgento/store.rb +31 -0
- data/app/models/gemgento/store_tag.rb +8 -0
- data/app/models/gemgento/subscriber.rb +30 -0
- data/app/models/gemgento/swatch.rb +9 -0
- data/app/models/gemgento/sync.rb +134 -0
- data/app/models/gemgento/tag.rb +64 -0
- data/app/models/gemgento/user.rb +161 -0
- data/app/models/gemgento/user_group.rb +13 -0
- data/app/models/gemgento/wishlist_item.rb +11 -0
- data/app/services/gemgento/magento_api.rb +173 -0
- data/app/services/gemgento/price.rb +67 -0
- data/app/validators/gemgento/credit_card_validator.rb +50 -0
- data/app/validators/gemgento/image_import_validator.rb +100 -0
- data/app/validators/gemgento/inventory_import_validator.rb +73 -0
- data/app/validators/gemgento/inventory_validator.rb +14 -0
- data/app/validators/gemgento/product_import_validator.rb +163 -0
- data/app/views/admin/product_positions/_index.html.haml +14 -0
- data/app/views/devise/registrations/edit.haml +37 -0
- data/app/views/gemgento/addresses/_address.json.jbuilder +6 -0
- data/app/views/gemgento/addresses/region_options.html.haml +1 -0
- data/app/views/gemgento/api/v1/categories/_category.json.jbuilder +52 -0
- data/app/views/gemgento/api/v1/categories/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/categories/show.json.jbuilder +7 -0
- data/app/views/gemgento/api/v1/products/_attributes.json.jbuilder +9 -0
- data/app/views/gemgento/api/v1/products/_product.json.jbuilder +18 -0
- data/app/views/gemgento/api/v1/products/_relationships.json.jbuilder +48 -0
- data/app/views/gemgento/api/v1/products/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/products/show.json.jbuilder +7 -0
- data/app/views/gemgento/api/v1/search/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/search/show.json.jbuilder +8 -0
- data/app/views/gemgento/assets/_asset.json.jbuilder +13 -0
- data/app/views/gemgento/cart/show.html.haml +67 -0
- data/app/views/gemgento/categories/_category.json.jbuilder +9 -0
- data/app/views/gemgento/categories/_product_tile.html.haml +16 -0
- data/app/views/gemgento/categories/index.html.haml +10 -0
- data/app/views/gemgento/categories/index.json.jbuilder +1 -0
- data/app/views/gemgento/categories/show.html.haml +16 -0
- data/app/views/gemgento/categories/show.json.jbuilder +1 -0
- data/app/views/gemgento/checkout/_checkout_header.html.haml +17 -0
- data/app/views/gemgento/checkout/address/error.js.erb +1 -0
- data/app/views/gemgento/checkout/address/show.html.haml +88 -0
- data/app/views/gemgento/checkout/address/success.js.erb +1 -0
- data/app/views/gemgento/checkout/confirm/error.js.erb +0 -0
- data/app/views/gemgento/checkout/confirm/show.html.haml +60 -0
- data/app/views/gemgento/checkout/confirm/success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_guest_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_guest_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/registration_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/registration_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/show.html.haml +50 -0
- data/app/views/gemgento/checkout/payment/error.js.erb +1 -0
- data/app/views/gemgento/checkout/payment/show.html.haml +56 -0
- data/app/views/gemgento/checkout/payment/success.js.erb +1 -0
- data/app/views/gemgento/checkout/shipping/error.js.erb +0 -0
- data/app/views/gemgento/checkout/shipping/show.html.haml +26 -0
- data/app/views/gemgento/checkout/shipping/success.js.erb +1 -0
- data/app/views/gemgento/checkout/shipping_payment/show.haml +52 -0
- data/app/views/gemgento/checkout/thank_you/show.html.haml +6 -0
- data/app/views/gemgento/countries/_country.json.jbuilder +4 -0
- data/app/views/gemgento/countries/index.json.jbuilder +3 -0
- data/app/views/gemgento/countries/show.json.jbuilder +1 -0
- data/app/views/gemgento/home/index.html.haml +1 -0
- data/app/views/gemgento/order/add_item.js.erb +0 -0
- data/app/views/gemgento/order/no_inventory.js.erb +1 -0
- data/app/views/gemgento/order/remove_item.js.erb +0 -0
- data/app/views/gemgento/order/update_item.js.erb +0 -0
- data/app/views/gemgento/order_export/index.html.haml +2 -0
- data/app/views/gemgento/order_items/_order_item.json.jbuilder +7 -0
- data/app/views/gemgento/orders/_order.json.jbuilder +29 -0
- data/app/views/gemgento/products/_product.json.jbuilder +40 -0
- data/app/views/gemgento/products/index.html.haml +19 -0
- data/app/views/gemgento/products/show.html.haml +67 -0
- data/app/views/gemgento/products/show.json.jbuilder +1 -0
- data/app/views/gemgento/sales_mailer/credit_memo_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/invoice_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/order_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/shipment_email.html.haml +1 -0
- data/app/views/gemgento/search/index.html.haml +8 -0
- data/app/views/gemgento/shared/_asset.json.jbuilder +35 -0
- data/app/views/gemgento/shared/_asset_file.json.jbuilder +19 -0
- data/app/views/gemgento/shared/_asset_type.json.jbuilder +13 -0
- data/app/views/gemgento/shared/_error_messages.haml +7 -0
- data/app/views/gemgento/shared/_flash_messages.haml +4 -0
- data/app/views/gemgento/shared/_footer.haml +7 -0
- data/app/views/gemgento/shared/_header.haml +23 -0
- data/app/views/gemgento/shared/_mini_bag.haml +36 -0
- data/app/views/gemgento/shared/_product_image.haml +8 -0
- data/app/views/gemgento/shipments/_shipment.json.jbuilder +12 -0
- data/app/views/gemgento/subscribers/create.js.erb +2 -0
- data/app/views/gemgento/subscribers/errors.js.erb +1 -0
- data/app/views/gemgento/user/_user.json.jbuilder +2 -0
- data/app/views/gemgento/user/addresses/_form.haml +39 -0
- data/app/views/gemgento/user/addresses/errors.js.erb +1 -0
- data/app/views/gemgento/user/addresses/index.haml +33 -0
- data/app/views/gemgento/user/addresses/new.haml +11 -0
- data/app/views/gemgento/user/addresses/success.js.erb +1 -0
- data/app/views/gemgento/user/confirmations/new.haml +9 -0
- data/app/views/gemgento/user/home/index.haml +8 -0
- data/app/views/gemgento/user/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/gemgento/user/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/gemgento/user/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/gemgento/user/orders/index.html.haml +29 -0
- data/app/views/gemgento/user/orders/show.html.haml +87 -0
- data/app/views/gemgento/user/passwords/edit.html.erb +18 -0
- data/app/views/gemgento/user/passwords/new.html.haml +21 -0
- data/app/views/gemgento/user/registration_session/new.haml +67 -0
- data/app/views/gemgento/user/registrations/new.html.haml +28 -0
- data/app/views/gemgento/user/saved_credit_cards/_form.haml +69 -0
- data/app/views/gemgento/user/saved_credit_cards/index.haml +25 -0
- data/app/views/gemgento/user/saved_credit_cards/new.haml +13 -0
- data/app/views/gemgento/user/sessions/new.html.haml +29 -0
- data/app/views/gemgento/user/shared/_links.erb +25 -0
- data/app/views/gemgento/user/shared/_user_header.haml +8 -0
- data/app/views/gemgento/user/wishlist_items/index.html.haml +20 -0
- data/app/views/kaminari/_first_page.html.haml +9 -0
- data/app/views/kaminari/_gap.html.haml +8 -0
- data/app/views/kaminari/_last_page.html.haml +9 -0
- data/app/views/kaminari/_next_page.html.haml +9 -0
- data/app/views/kaminari/_page.html.haml +10 -0
- data/app/views/kaminari/_paginator.html.haml +18 -0
- data/app/views/kaminari/_prev_page.html.haml +9 -0
- data/app/views/layouts/_footer.html.haml +5 -0
- data/app/views/layouts/_header.html.haml +39 -0
- data/app/views/layouts/gemgento.html.haml +22 -0
- data/app/workers/gemgento/apply_price_rule.rb +24 -0
- data/app/workers/gemgento/cart/add_item_worker.rb +23 -0
- data/app/workers/gemgento/cart/update_item_worker.rb +18 -0
- data/bin/rails +12 -0
- data/config/gemgento_config.yml +12 -0
- data/config/initializers/active_admin.rb +14 -0
- data/config/initializers/active_touch.rb +3 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/boolean_typecasting.rb +37 -0
- data/config/initializers/devise.rb +49 -0
- data/config/initializers/gemgento_config.rb +67 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/state_machine.rb +7 -0
- data/config/locales/en.yml +24 -0
- data/config/routes.rb +138 -0
- data/db/migrate/20151201231300_add_validation_indexes_to_gemgento_products.rb +22 -0
- data/db/migrate/20160122174450_gemgento2.rb +969 -0
- data/db/migrate/20160217142910_create_gemgento_imports.rb +15 -0
- data/db/migrate/20160219235858_add_timestamps_to_gemgento_asset_files.rb +6 -0
- data/gemgento.gemspec +44 -0
- data/lib/devise/models/validatable.rb +76 -0
- data/lib/gemgento.rb +24 -0
- data/lib/gemgento/admin/admin_user.rb +29 -0
- data/lib/gemgento/admin/api_jobs.rb +30 -0
- data/lib/gemgento/admin/image_import.rb +87 -0
- data/lib/gemgento/admin/inventory_import.rb +81 -0
- data/lib/gemgento/admin/product_import.rb +138 -0
- data/lib/gemgento/admin/product_positions.rb +49 -0
- data/lib/gemgento/admin/stores.rb +33 -0
- data/lib/gemgento/admin/subscribers.rb +31 -0
- data/lib/gemgento/admin/syncs.rb +26 -0
- data/lib/gemgento/api/soap/authnetcim/payment.rb +127 -0
- data/lib/gemgento/api/soap/catalog/category.rb +237 -0
- data/lib/gemgento/api/soap/catalog/product.rb +481 -0
- data/lib/gemgento/api/soap/catalog/product_attribute.rb +147 -0
- data/lib/gemgento/api/soap/catalog/product_attribute_media.rb +202 -0
- data/lib/gemgento/api/soap/catalog/product_attribute_set.rb +80 -0
- data/lib/gemgento/api/soap/catalog/product_tag.rb +146 -0
- data/lib/gemgento/api/soap/catalog/product_tier_price.rb +21 -0
- data/lib/gemgento/api/soap/catalog/search.rb +27 -0
- data/lib/gemgento/api/soap/catalog_inventory/stock_item.rb +87 -0
- data/lib/gemgento/api/soap/catalog_rule/rule.rb +54 -0
- data/lib/gemgento/api/soap/checkout/cart.rb +85 -0
- data/lib/gemgento/api/soap/checkout/coupon.rb +37 -0
- data/lib/gemgento/api/soap/checkout/customer.rb +87 -0
- data/lib/gemgento/api/soap/checkout/payment.rb +59 -0
- data/lib/gemgento/api/soap/checkout/product.rb +138 -0
- data/lib/gemgento/api/soap/checkout/shipping.rb +37 -0
- data/lib/gemgento/api/soap/customer/address.rb +143 -0
- data/lib/gemgento/api/soap/customer/customer.rb +200 -0
- data/lib/gemgento/api/soap/directory/country.rb +49 -0
- data/lib/gemgento/api/soap/directory/region.rb +50 -0
- data/lib/gemgento/api/soap/enterprise_gift_message/gift_message.rb +26 -0
- data/lib/gemgento/api/soap/gift_card.rb +35 -0
- data/lib/gemgento/api/soap/globalcollect/saved_cc.rb +58 -0
- data/lib/gemgento/api/soap/miscellaneous/store.rb +47 -0
- data/lib/gemgento/api/soap/sales/order.rb +249 -0
- data/lib/gemgento/api/soap/sales/order_shipment.rb +122 -0
- data/lib/gemgento/api/soap/sales/recurring_profile.rb +88 -0
- data/lib/gemgento/api/soap/stock_notification.rb +27 -0
- data/lib/gemgento/engine.rb +61 -0
- data/lib/gemgento/version.rb +3 -0
- data/lib/generators/gemgento/assets_generator.rb +11 -0
- data/lib/generators/gemgento/install_generator.rb +34 -0
- data/lib/generators/gemgento/templates/active_admin.css.scss +1 -0
- data/lib/generators/gemgento/templates/active_admin.js.coffee +1 -0
- data/lib/generators/gemgento/templates/active_admin.rb +3 -0
- data/lib/generators/gemgento/views_generator.rb +10 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +20 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/gemgento_config.yml +22 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/gemgento/price_tiers.rb +8 -0
- data/spec/factories/gemgento/product_attribute_sets.rb +22 -0
- data/spec/factories/gemgento/product_attributes.rb +5 -0
- data/spec/factories/gemgento/products.rb +14 -0
- data/spec/factories/gemgento/stores.rb +12 -0
- data/spec/factories/gemgento/user_groups.rb +6 -0
- data/spec/factories/gemgento/users.rb +13 -0
- data/spec/factories/gemgento_imports.rb +12 -0
- data/spec/model/gemgento/price_tier_spec.rb +45 -0
- data/spec/rails_helper.rb +55 -0
- data/spec/services/gemgento/price_spec.rb +152 -0
- data/spec/spec_helper.rb +87 -0
- metadata +919 -0
@@ -0,0 +1,147 @@
|
|
1
|
+
module Gemgento
|
2
|
+
module API
|
3
|
+
module SOAP
|
4
|
+
module Catalog
|
5
|
+
class ProductAttribute
|
6
|
+
|
7
|
+
def self.fetch_all
|
8
|
+
::Gemgento::ProductAttributeSet.all.each do |product_attribute_set|
|
9
|
+
list(product_attribute_set).each do |product_attribute|
|
10
|
+
sync_magento_to_local(info(product_attribute[:attribute_id]), product_attribute_set)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.fetch(attribute_id, attribute_set)
|
16
|
+
attribute_info = info(attribute_id)
|
17
|
+
sync_magento_to_local(attribute_info, attribute_set)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.fetch_all_options(product_attribute)
|
21
|
+
option_ids = []
|
22
|
+
|
23
|
+
# add attribute options if there are any
|
24
|
+
Store.all.each do |store|
|
25
|
+
options(product_attribute.magento_id, store).each_with_index do |attribute_option, index|
|
26
|
+
label = MagentoApi.enforce_savon_string(attribute_option[:label])
|
27
|
+
value = MagentoApi.enforce_savon_string(attribute_option[:value])
|
28
|
+
|
29
|
+
product_attribute_option = ProductAttributeOption.find_or_initialize_by(product_attribute: product_attribute, value: value, store: store)
|
30
|
+
product_attribute_option.label = label
|
31
|
+
product_attribute_option.order = index
|
32
|
+
product_attribute_option.sync_needed = false
|
33
|
+
product_attribute_option.save
|
34
|
+
|
35
|
+
option_ids << product_attribute_option.id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
product_attribute.product_attribute_options.where.not(id: option_ids).destroy_all
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.list(product_attribute_set)
|
43
|
+
response = MagentoApi.create_call(:catalog_product_attribute_list, {set_id: product_attribute_set.magento_id})
|
44
|
+
|
45
|
+
if response.success?
|
46
|
+
unless response.body[:result][:item].is_a? Array
|
47
|
+
response.body[:result][:item] = [response.body[:result][:item]]
|
48
|
+
end
|
49
|
+
|
50
|
+
response.body[:result][:item]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.info(attribute_id)
|
55
|
+
response = MagentoApi.create_call(:catalog_product_attribute_info, {attribute: attribute_id})
|
56
|
+
|
57
|
+
if response.success?
|
58
|
+
response.body[:result]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.options(product_attribute_id, store)
|
63
|
+
message = {
|
64
|
+
attributeId: product_attribute_id,
|
65
|
+
storeView: store.magento_id
|
66
|
+
}
|
67
|
+
response = MagentoApi.create_call(:catalog_product_attribute_options, message)
|
68
|
+
|
69
|
+
if response.success?
|
70
|
+
if response.body[:result][:item].nil?
|
71
|
+
response.body[:result][:item] = []
|
72
|
+
end
|
73
|
+
|
74
|
+
unless response.body[:result][:item].is_a? Array
|
75
|
+
response.body[:result][:item] = [response.body[:result][:item]]
|
76
|
+
end
|
77
|
+
|
78
|
+
response.body[:result][:item]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.types
|
83
|
+
# TODO: Create types API call
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.create(product_attribute)
|
87
|
+
# TODO: create a new product attribute set on Magento
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.update(product_attribute)
|
91
|
+
# TODO: update a product attribute set on Magento
|
92
|
+
end
|
93
|
+
|
94
|
+
# Add an attribute option in Magento.
|
95
|
+
#
|
96
|
+
# @param product_attribute_option [Gemgento::ProductAttributeOption]
|
97
|
+
# @param product_attribute [Gemgento::ProductAttribute]
|
98
|
+
# @return [Gemgento::MagentoResponse]
|
99
|
+
def self.add_option(product_attribute_option, product_attribute)
|
100
|
+
message = {attribute: product_attribute.magento_id, data: {
|
101
|
+
label: {item: [{'store_id' => {item: Store.all.map { |s| s.magento_id.to_s } << 0}, value: product_attribute_option.label}]},
|
102
|
+
order: '0',
|
103
|
+
'is_default' => '0'
|
104
|
+
}}
|
105
|
+
|
106
|
+
response = MagentoApi.create_call(:catalog_product_attribute_add_option, message)
|
107
|
+
fetch_all_options(product_attribute) if response.success?
|
108
|
+
|
109
|
+
return response
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.remove_option
|
113
|
+
# TODO: update a product attribute set on Magento
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
# Save Magento product attribute set to local
|
119
|
+
def self.sync_magento_to_local(source, product_attribute_set)
|
120
|
+
unless ::Gemgento::ProductAttribute.ignored.include?(source[:attribute_code])
|
121
|
+
product_attribute = ::Gemgento::ProductAttribute.find_or_initialize_by(magento_id: source[:attribute_id])
|
122
|
+
product_attribute.magento_id = source[:attribute_id]
|
123
|
+
product_attribute.product_attribute_sets << product_attribute_set unless product_attribute.product_attribute_sets.include? product_attribute_set
|
124
|
+
product_attribute.code = source[:attribute_code]
|
125
|
+
product_attribute.frontend_input = source[:frontend_input]
|
126
|
+
product_attribute.scope = source[:scope]
|
127
|
+
product_attribute.default_value = source[:default_value] == {:'@xsi:type' => 'xsd:string'} ? nil : source[:default_value]
|
128
|
+
product_attribute.is_unique = source[:is_unique]
|
129
|
+
product_attribute.is_required = source[:is_required]
|
130
|
+
product_attribute.is_configurable = source[:is_configurable]
|
131
|
+
product_attribute.is_searchable = source[:is_searchable]
|
132
|
+
product_attribute.is_visible_in_advanced_search = source[:is_visible_in_advanced_search]
|
133
|
+
product_attribute.is_comparable = source[:is_comparable]
|
134
|
+
product_attribute.is_used_for_promo_rules = source[:is_used_for_promo_rules]
|
135
|
+
product_attribute.is_visible_on_front = source[:is_visible_on_front]
|
136
|
+
product_attribute.used_in_product_listing = source[:used_in_product_listing]
|
137
|
+
product_attribute.sync_needed = false
|
138
|
+
product_attribute.save
|
139
|
+
|
140
|
+
fetch_all_options(product_attribute) if product_attribute.frontend_input == 'select'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
module Gemgento
|
2
|
+
module API
|
3
|
+
module SOAP
|
4
|
+
module Catalog
|
5
|
+
class ProductAttributeMedia
|
6
|
+
|
7
|
+
def self.fetch_all
|
8
|
+
::Gemgento::Store.all.each do |store|
|
9
|
+
::Gemgento::Product.active.each do |product|
|
10
|
+
fetch(product, store)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.fetch(product, store = nil)
|
16
|
+
store = ::Gemgento::Store.current if store.nil?
|
17
|
+
response = list(product, store)
|
18
|
+
|
19
|
+
if response.success?
|
20
|
+
assets_to_keep = []
|
21
|
+
|
22
|
+
response.body[:result][:item].each do |product_attribute_media|
|
23
|
+
if asset = sync_magento_to_local(product_attribute_media, product, store)
|
24
|
+
assets_to_keep << asset.id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# destroy any assets that were not in the media gallery for each store
|
29
|
+
::Gemgento::Asset.skip_callback(:destroy, :before, :delete_magento)
|
30
|
+
product.assets.where(store: store).where.not(id: assets_to_keep).destroy_all
|
31
|
+
::Gemgento::Asset.set_callback(:destroy, :before, :delete_magento)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.fetch_all_media_types
|
36
|
+
::Gemgento::ProductAttributeSet.all.each do |product_attribute_set|
|
37
|
+
response = types(product_attribute_set)
|
38
|
+
|
39
|
+
if response.success?
|
40
|
+
response.body[:result][:item].each do |media_type|
|
41
|
+
sync_magento_media_type_to_local(media_type, product_attribute_set)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.list(product, store)
|
48
|
+
message = {
|
49
|
+
product: product.magento_id,
|
50
|
+
identifier_type: 'id',
|
51
|
+
store_view: store.magento_id
|
52
|
+
}
|
53
|
+
response = ::Gemgento::MagentoApi.create_call(:catalog_product_attribute_media_list, message)
|
54
|
+
|
55
|
+
if response.success?
|
56
|
+
if response.body[:result][:item].nil?
|
57
|
+
response.body[:result][:item] = []
|
58
|
+
elsif !response.body[:result][:item].is_a? Array
|
59
|
+
response.body[:result][:item] = [response.body[:result][:item]]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
return response
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.info
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
# Create a Product Attribute Media in Magento.
|
71
|
+
#
|
72
|
+
# @param asset [Gemgento::Asset]
|
73
|
+
# @return [Gemgento::MagentoResponse]
|
74
|
+
def self.create(asset)
|
75
|
+
message = {
|
76
|
+
product: asset.product.magento_id,
|
77
|
+
data: compose_asset_entity_data(asset, true),
|
78
|
+
identifier_type: 'id',
|
79
|
+
store_view: asset.store.magento_id
|
80
|
+
}
|
81
|
+
::Gemgento::MagentoApi.create_call(:catalog_product_attribute_media_create, message)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Update a Product Attribute Media in Magento.
|
85
|
+
#
|
86
|
+
# @param asset [Gemgento::Asset]
|
87
|
+
# @return [Gemgento::MagentoResponse]
|
88
|
+
def self.update(asset)
|
89
|
+
message = {
|
90
|
+
product: asset.product.magento_id,
|
91
|
+
file: asset.file,
|
92
|
+
data: compose_asset_entity_data(asset, false),
|
93
|
+
identifier_type: 'id',
|
94
|
+
store_view: asset.store.magento_id
|
95
|
+
}
|
96
|
+
::Gemgento::MagentoApi.create_call(:catalog_product_attribute_media_update, message)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Remove Product Attribute Media in Magento.
|
100
|
+
#
|
101
|
+
# @param asset [Gemgento::Asset]
|
102
|
+
# @return [Gemgento::MagentoResponse]
|
103
|
+
def self.remove(asset)
|
104
|
+
message = { product: asset.product.magento_id, file: asset.file, identifier_type: 'id' }
|
105
|
+
::Gemgento::MagentoApi.create_call(:catalog_product_attribute_media_remove, message)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get Product Attribute Media Types from Magento.
|
109
|
+
#
|
110
|
+
# @param product_attribute_set [Gemgento::ProductAttributeSet]
|
111
|
+
# @return [Gemgento::MagnetoRepsonse]
|
112
|
+
def self.types(product_attribute_set)
|
113
|
+
response = ::Gemgento::MagentoApi.create_call(:catalog_product_attribute_media_types, {set_id: product_attribute_set.magento_id})
|
114
|
+
|
115
|
+
if response.success? &&
|
116
|
+
if response.body[:result][:item].nil?
|
117
|
+
response.body[:result][:item] = []
|
118
|
+
elsif !response.body[:result][:item].is_a?(Array)
|
119
|
+
response.body[:result][:item] = [response.body[:result][:item]]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
return response
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
# Save Magento product attribute set to local
|
129
|
+
# @return [Gemgento::Asset]
|
130
|
+
def self.sync_magento_to_local(source, product, store)
|
131
|
+
return false unless ::Gemgento::AssetFile.valid_url(source[:url])
|
132
|
+
|
133
|
+
asset = ::Gemgento::Asset.find_or_initialize_by(product_id: product.id, file: source[:file], store_id: store.id)
|
134
|
+
asset.url = source[:url]
|
135
|
+
asset.position = source[:position]
|
136
|
+
asset.label = ::Gemgento::MagentoApi.enforce_savon_string(source[:label])
|
137
|
+
asset.file = source[:file]
|
138
|
+
asset.product = product
|
139
|
+
asset.sync_needed = false
|
140
|
+
asset.store = store
|
141
|
+
asset.set_file ::Gemgento::AssetFile.from_url(source[:url])
|
142
|
+
asset.save
|
143
|
+
|
144
|
+
# assign AssetTypes
|
145
|
+
asset_type_codes = source[:types][:item]
|
146
|
+
asset_type_codes = [::Gemgento::MagentoApi.enforce_savon_string(asset_type_codes)] unless asset_type_codes.is_a? Array
|
147
|
+
asset.set_types_by_codes(asset_type_codes)
|
148
|
+
|
149
|
+
return asset
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.sync_magento_media_type_to_local(source, product_attribute_set)
|
153
|
+
asset_type = ::Gemgento::AssetType.find_or_initialize_by(product_attribute_set: product_attribute_set, code: source[:code])
|
154
|
+
asset_type.scope = source[:scope]
|
155
|
+
asset_type.save
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.compose_asset_entity_data(asset, include_file = true)
|
159
|
+
asset_entity = {
|
160
|
+
label: asset.label,
|
161
|
+
position: asset.position,
|
162
|
+
types: {item: compose_types(asset)},
|
163
|
+
exclude: '0'
|
164
|
+
}
|
165
|
+
|
166
|
+
if include_file
|
167
|
+
asset_entity[:file] = compose_file_entity(asset.asset_file)
|
168
|
+
end
|
169
|
+
|
170
|
+
asset_entity
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.compose_file_entity(asset_file)
|
174
|
+
if asset_file.file.url(:original) =~ URI::regexp
|
175
|
+
content = open(asset_file.file.url(:original)).read
|
176
|
+
else
|
177
|
+
content = File.open(asset_file.file.path(:original)).read
|
178
|
+
end
|
179
|
+
|
180
|
+
file_entity = {
|
181
|
+
content: Base64.encode64(content),
|
182
|
+
mime: asset_file.file_content_type
|
183
|
+
}
|
184
|
+
|
185
|
+
file_entity
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.compose_types(asset)
|
189
|
+
types = []
|
190
|
+
|
191
|
+
asset.asset_types.each do |asset_type|
|
192
|
+
types << asset_type.code
|
193
|
+
end
|
194
|
+
|
195
|
+
types
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Gemgento
|
2
|
+
module API
|
3
|
+
module SOAP
|
4
|
+
module Catalog
|
5
|
+
class ProductAttributeSet
|
6
|
+
|
7
|
+
# Pull all Magento ProductAttributeSet data into Gemgento.
|
8
|
+
#
|
9
|
+
# @return [Void]
|
10
|
+
def self.fetch_all
|
11
|
+
response = list
|
12
|
+
|
13
|
+
if response.success?
|
14
|
+
response.body[:result][:item].each do |product_attribute_set|
|
15
|
+
sync_magento_to_local(product_attribute_set)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get a list of ProductAttributeSets from Magento.
|
21
|
+
#
|
22
|
+
# @return [Gemgento::MagentoResponse]
|
23
|
+
def self.list
|
24
|
+
response = MagentoApi.create_call(:catalog_product_attribute_set_list)
|
25
|
+
|
26
|
+
if response.success?
|
27
|
+
response.body[:result][:item] = [response.body[:result][:item]] unless response.body[:result][:item].is_a? Array
|
28
|
+
end
|
29
|
+
|
30
|
+
return response
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create a new product attribute set in Magento
|
34
|
+
def self.create
|
35
|
+
# TODO: create a new product attribute set on Magento
|
36
|
+
end
|
37
|
+
|
38
|
+
# Update existing Magento product attribute set
|
39
|
+
def self.update
|
40
|
+
# TODO: update a product attribute set on Magento
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.attribute_add
|
44
|
+
# TODO: add an attribute to a set on Magento
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.attribute_remove
|
48
|
+
# TODO: remove an attribute from a set on Magento
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.group_add
|
52
|
+
# TODO: add a new group for attributes in the set on Magento
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.group_remove
|
56
|
+
# TODO: remove a group of attributes in the set on Magento
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.group_rename
|
60
|
+
# TODO: rename a group in the set on Magento
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
# Save Magento product attribute set to local.
|
66
|
+
#
|
67
|
+
# @return [Void]
|
68
|
+
def self.sync_magento_to_local(source)
|
69
|
+
product_attribute_set = ::Gemgento::ProductAttributeSet.where(magento_id: source[:set_id]).first_or_initialize
|
70
|
+
product_attribute_set.magento_id = source[:set_id]
|
71
|
+
product_attribute_set.name = source[:name]
|
72
|
+
product_attribute_set.sync_needed = false
|
73
|
+
product_attribute_set.save
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module Gemgento
|
2
|
+
module API
|
3
|
+
module SOAP
|
4
|
+
module Catalog
|
5
|
+
class ProductTag
|
6
|
+
|
7
|
+
# Fetch all product tags from Magento.
|
8
|
+
#
|
9
|
+
# @return [Void]
|
10
|
+
def self.fetch_all
|
11
|
+
Product.not_deleted.where(magento_id: [391]).each do |product|
|
12
|
+
product.stores.each do |store|
|
13
|
+
list_response = list product, store
|
14
|
+
|
15
|
+
if list_response.success?
|
16
|
+
|
17
|
+
list_response.body[:result][:item].each do |tag|
|
18
|
+
info_response = info tag[:tag_id], store
|
19
|
+
|
20
|
+
if info_response.success?
|
21
|
+
sync_magento_to_local tag[:tag_id], info_response.body[:result], store
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieve a list of tags related to a product and store.
|
30
|
+
#
|
31
|
+
# @param product [Product]
|
32
|
+
# @param store [Store]
|
33
|
+
# @return [Gemgento::MagentoResponse]
|
34
|
+
def self.list(product, store)
|
35
|
+
message = {
|
36
|
+
product_id: product.magento_id,
|
37
|
+
store: store.magento_id
|
38
|
+
}
|
39
|
+
response = MagentoApi.create_call(:catalog_product_tag_list, message)
|
40
|
+
|
41
|
+
if response.success?
|
42
|
+
response.body[:result][:item] = [response.body[:result][:item]] unless response.body[:result][:item].is_a? Array
|
43
|
+
end
|
44
|
+
|
45
|
+
return response
|
46
|
+
end
|
47
|
+
|
48
|
+
# Retrieve info on a specific tag.
|
49
|
+
#
|
50
|
+
# @param magento_tag_id [Gemgento::Integer]
|
51
|
+
# @param store [Gemgento::Store]
|
52
|
+
# @return [Gemgento::MagentoResponse]
|
53
|
+
def self.info(magento_tag_id, store)
|
54
|
+
message = {
|
55
|
+
tag_id: magento_tag_id,
|
56
|
+
store: store.magento_id
|
57
|
+
}
|
58
|
+
MagentoApi.create_call(:catalog_product_tag_info, message)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Sync a Magento tag to Gemgento.
|
62
|
+
#
|
63
|
+
# @param magento_tag_id [Integer]
|
64
|
+
# @param source [Hash]
|
65
|
+
# @param store [Store]
|
66
|
+
def self.sync_magento_to_local(magento_tag_id, source, store)
|
67
|
+
tag = Tag.find_or_initialize_by(magento_id: magento_tag_id)
|
68
|
+
tag.name = source[:name]
|
69
|
+
tag.sync_needed = false
|
70
|
+
tag.save
|
71
|
+
|
72
|
+
store_tag = StoreTag.find_or_initialize_by(store: store, tag: tag)
|
73
|
+
store_tag.base_popularity = source[:base_popularity]
|
74
|
+
store_tag.save
|
75
|
+
|
76
|
+
associate_products(tag, source[:products][:item]) if source[:products][:item]
|
77
|
+
end
|
78
|
+
|
79
|
+
# Associate a tag using a set of magento product ids.
|
80
|
+
#
|
81
|
+
# @param tag [Tag]
|
82
|
+
# @param source_product_ids [Hash, Array(Hash)]
|
83
|
+
# @return [Void]
|
84
|
+
def self.associate_products(tag, source_product_ids)
|
85
|
+
product_ids = []
|
86
|
+
source_product_ids = [source_product_ids] unless source_product_ids.is_a? Array
|
87
|
+
|
88
|
+
source_product_ids.each do |product_key|
|
89
|
+
Product.unscoped do
|
90
|
+
if product = Product.not_deleted.find_by(magento_id: product_key[:key])
|
91
|
+
tag.products << product unless tag.products.include? product
|
92
|
+
product_ids << product.id
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
tag.products.where('gemgento_products.id NOT IN (?)', product_ids).destroy_all
|
98
|
+
end
|
99
|
+
|
100
|
+
# Add tags to a product.
|
101
|
+
#
|
102
|
+
# @param tags [Array(Tag)]
|
103
|
+
# @param products [Product]
|
104
|
+
# @param store [Store]
|
105
|
+
# @param user [User]
|
106
|
+
# @return [Gemgento::MagentoResponse]
|
107
|
+
def self.add(tags, product, store, user = nil)
|
108
|
+
message = {
|
109
|
+
tag: "'#{tags.map(&:name).join("', '")}'",
|
110
|
+
product_id: product.magento_id,
|
111
|
+
store: store.magento_id
|
112
|
+
}
|
113
|
+
message[:customer_id] = user.magento_id unless user.nil?
|
114
|
+
|
115
|
+
response = MagentoApi.create_call(:catalog_product_tag_info, message)
|
116
|
+
|
117
|
+
if response.success?
|
118
|
+
response.body[:result][:item] = [response.body[:result][:item]] unless response.body[:result][:item].is_a?(Array)
|
119
|
+
end
|
120
|
+
|
121
|
+
return response
|
122
|
+
end
|
123
|
+
|
124
|
+
# Manage a tag, this will create/update a tag with absolute values.
|
125
|
+
#
|
126
|
+
# @param tag [Tag]
|
127
|
+
# @param store [Store]
|
128
|
+
# @return [Gemgento::MagentoResponse]
|
129
|
+
def self.manage(tag, store)
|
130
|
+
message = {
|
131
|
+
name: tag.name,
|
132
|
+
status: tag.status,
|
133
|
+
base_popularity: tag.base_popularity(store),
|
134
|
+
product_ids: {item: tag.products.map(&:magento_id)},
|
135
|
+
store: store.magento_id
|
136
|
+
}
|
137
|
+
message[:tag_id] = tag.magento_id unless tag.magento_id.nil?
|
138
|
+
|
139
|
+
MagentoApi.create_call(:catalog_product_tag_manage, message)
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|