Class: Gemgento::MagentoDB
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gemgento::MagentoDB
- Defined in:
- app/models/gemgento/magento_db.rb
Overview
Class Method Summary collapse
-
.associated_simple_products(configurable_product) ⇒ Array(Gemgento::Product)
Associate configurable and simple Products by reading directly from the Magento table with the association data.
-
.query(table_name) ⇒ ActiveRecord::Result
Query the Magento database using ActiveRecord.
Class Method Details
.associated_simple_products(configurable_product) ⇒ Array(Gemgento::Product)
Associate configurable and simple Products by reading directly from the Magento table with the association data.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/gemgento/magento_db.rb', line 10 def self.associated_simple_products(configurable_product) establish_connection("magento_#{Rails.env}".to_sym) self.table_name = "#{Config[:magento][:table_prefix]}catalog_product_super_link" simple_products = [] self.where('parent_id = ?', configurable_product.magento_id).each do |association| simple_product = Product.where(magento_id: association.product_id).first simple_products << simple_product unless simple_product.nil? end simple_products end |
.query(table_name) ⇒ ActiveRecord::Result
Query the Magento database using ActiveRecord.
28 29 30 31 32 33 |
# File 'app/models/gemgento/magento_db.rb', line 28 def self.query(table_name) establish_connection("magento_#{Rails.env}".to_sym) self.table_name = Config[:magento][:table_prefix] + table_name return self end |