def get_attribute_sets(self, cursor, user, context=None): """Get the list of attribute sets from magento for the current website's instance :param cursor: Database cursor :param user: ID of current user :param context: Application context :return: Tuple of attribute sets where each tuple consists of (ID, Name) """ website_obj = self.pool.get('magento.instance.website') if not context.get('active_id'): return [] website = website_obj.browse(cursor, user, context['active_id'], context) instance = website.instance with magento.ProductAttributeSet( instance.url, instance.api_user, instance.api_key) as attribute_set_api: attribute_sets = attribute_set_api.list() return [(attribute_set['set_id'], attribute_set['name']) for attribute_set in attribute_sets]
def get_attribute_sets(cls): """Get the list of attribute sets from magento for the current channel :return: Tuple of attribute sets where each tuple consists of (ID,Name) """ Channel = Pool().get('sale.channel') if not Transaction().context.get('active_id'): return [] channel = Channel(Transaction().context['active_id']) channel.validate_magento_channel() with magento.ProductAttributeSet( channel.magento_url, channel.magento_api_user, channel.magento_api_key) as attribute_set_api: attribute_sets = attribute_set_api.list() return [(attribute_set['set_id'], attribute_set['name']) for attribute_set in attribute_sets]
def get_attribute_sets(cls): """Get the list of attribute sets from magento for the current website :return: Tuple of attribute sets where each tuple consists of (ID,Name) """ Website = Pool().get('magento.instance.website') if not Transaction().context.get('active_id'): return [] website = Website(Transaction().context['active_id']) instance = website.instance with magento.ProductAttributeSet( instance.url, instance.api_user, instance.api_key ) as attribute_set_api: attribute_sets = attribute_set_api.list() return [( attribute_set['set_id'], attribute_set['name'] ) for attribute_set in attribute_sets]
def get_attribute_sets(self, cr, uid, ids, context={}): website = self.browse(cr, uid, ids[0], context) instance = website.instance with magento.ProductAttributeSet( instance.url, instance.api_user, instance.api_key) as attribute_set_api: attribute_sets = attribute_set_api.list() magento_web_attr_obj = self.pool.get('magento.attributes') for attribute in attribute_sets: set_id = self.pool.get('magento.attributes').search( cr, uid, [('set_id', '=', attribute['set_id'])]) if not set_id: magento_web_attr_obj.create( cr, uid, { 'set_id': attribute['set_id'], 'website_id': ids[0], 'name': attribute['name'] }) return True