GET /admin/products/:id/variants
 GET /admin/products/:id/variants/:variant_id
978311
def admin_edit_variants   
      return if !user_is_allowed('products', 'edit')    
      @product = Product.find(params[:id])
      
      if @product.variants.nil? || @product.variants.count == 0
        v = Variant.new
        v.option1 = @product.default1 if @product.option1
        v.option2 = @product.default2 if @product.option2
        v.option3 = @product.default3 if @product.option3
        v.status  = 'Active'
        @product.variants = [v]
        @product.save
      end
      @variant = params[:variant_id] ? Variant.find(params[:variant_id]) : @product.variants[0]
      session['variant_cols'] = self.default_variant_cols if session['variant_cols'].nil?
      @cols = session['variant_cols']
      
      @highlight_variant_id = params[:highlight] ? params[:highlight].to_i : nil        
      
      if @product.options.nil? || @product.options.count == 0
        render 'caboose_store/products/admin_edit_variants_single', :layout => 'caboose/admin'  
      else
        render 'caboose_store/products/admin_edit_variants', :layout => 'caboose/admin'
      end          
    end
1097997
def get_version_name(version_id):
    
    ver = registry.version_info.get(version_id)
    if ver:
        return ver.name

    return 'unknown'
1020714
def find_by_id(self, custom_field, params={}, **options): 
        
        path = "/custom_fields/%s" % (custom_field)
        return self.client.get(path, params, **options)
1308947
public function getProductAllAttributes($variation = null)
    {
        if (null === $variation) {
            $variations = $this->productVariations()->get();
        }

        $collection = Collection::make([]);

        if (null === $variations || $variations->count() <= 0) {
            return $collection;
        }

        foreach ($variations as $variation) {
            $variationModel = self::findorfail($variation->variation_id);

            foreach ($variationModel->productVarcharAttributes as $item) {
                $collection->push($item);
            }
            foreach ($variationModel->productBooleanAttributes as $item) {
                $collection->push($item);
            }

            foreach ($variationModel->productTextAttributes as $item) {
                $collection->push($item);
            }
            foreach ($variationModel->productDecimalAttributes as $item) {
                $collection->push($item);
            }
            foreach ($variationModel->productDecimalAttributes as $item) {
                $collection->push($item);
            }
            foreach ($variationModel->productIntegerAttributes as $item) {
                $collection->push($item);
            }

            foreach ($variationModel->productDatetimeAttributes as $item) {
                $collection->push($item);
            }
        }

        return $collection;
    }
509306
def get_products(self, product_ids):
        
        if self.product_set_id is None:
            raise ValueError('product_set_id must be specified')
        data = {'ids': product_ids}
        return self.client.get(self.base_url + '/products', json=data)
1251730
def get_variant(self, identity, experiment_name):
        
        try:
            match = model.Participant.query.join(
                model.Experiment
            ).filter(and_(
                model.Participant.identity == identity,
                model.Experiment.name == experiment_name
            )).first()
            return match.variant.name if match else None
        finally:
            self.Session.close()
828216
def find_products(params)
      raise ArgumentError unless params[:CategoryID] or params[:ProductID] or params[:QueryKeywords] or
        (params[:'ProductID.Value'] && params[:'ProductID.type'])
      response = get_json_response(build_request_url('FindProducts', params))
      if response.response.has_key?('Product')
        response.results = response.response['Product']
      end
      return response
    end
1374238
def getMetadataId(self, metadata):
        
        return str(datamodel.VariantSetMetadataCompoundId(
            self.getCompoundId(), 'metadata:' + metadata.key))
871635
def identity(ctx, variant_id):
    
    if not variant_id:
        LOG.warning("Please provide a variant id")
        ctx.abort()

    adapter = ctx.obj['adapter']
    version = ctx.obj['version']
    
    LOG.info("Search variants {0}".format(adapter))
    
    result = adapter.get_clusters(variant_id)
    if result.count() == 0:
        LOG.info("No hits for variant %s", variant_id)
        return
    
    for res in result:
        click.echo(res)
1255650
def dynamic_content_item_variant_update(self, item_id, id, data, **kwargs):
        ""
        api_path = "/api/v2/dynamic_content/items/{item_id}/variants/{id}.json"
        api_path = api_path.format(item_id=item_id, id=id)
        return self.call(api_path, method="PUT", data=data, **kwargs)
128022
def get_variant_id(variant_dict=None, variant_line=None):
    
    
    if variant_dict:
        chrom = variant_dict['CHROM']
        position = variant_dict['POS']
        ref = variant_dict['REF']
        alt = variant_dict['ALT']
    elif variant_line:
        splitted_line = variant_line.rstrip().split('\t')
        chrom = splitted_line[0]
        position = splitted_line[1]
        ref = splitted_line[3]
        alt = splitted_line[4]
    else:
        raise Exception("Have to provide variant dict or variant line")
    
    return '_'.join([
        chrom,
        position,
        ref,
        alt,
    ])
615653
public function get_variants() {
        $variants = array_keys($this->variantstats);
        if (count($variants) > 1 || reset($variants) != 1) {
            return $variants;
        } else {
            return array();
        }
    }
1323521
private Map<String, VariantSet> getVariants(ResourceBrowser rsBrowser, String rootDir, String defaultSkinName,
			String defaultLocaleName, boolean mappingSkinLocale) {
		Set<String> paths = rsBrowser.getResourceNames(rootDir);
		Set<String> skinNames = new HashSet<>();
		Set<String> localeVariants = new HashSet<>();
		for (Iterator<String> itPath = paths.iterator(); itPath.hasNext();) {
			String path = rootDir + itPath.next();
			if (rsBrowser.isDirectory(path)) {
				String dirName = PathNormalizer.getPathName(path);
				if (mappingSkinLocale) {
					skinNames.add(dirName);
					// check if there are locale variants for this skin,
					// and update the localeVariants if needed
					updateLocaleVariants(rsBrowser, path, localeVariants);
				} else {
					if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) {
						localeVariants.add(dirName);
						// check if there are skin variants for this locales,
						// and update the skinVariants if needed
						updateSkinVariants(rsBrowser, path, skinNames);
					}
				}
			}
		}

		// Initialize the variant mapping for the skin root directory
		return getVariants(defaultSkinName, skinNames, defaultLocaleName, localeVariants);
	}
1307423
def admin_add
      return if !user_is_allowed('variants', 'add')
      resp = Caboose::StdClass.new(
        :error   => nil,
        :refresh => nil
      )
    
      p = Product.find(params[:id])
      v = Variant.new(:product_id => p.id)
      v.option1 = p.default1
      v.option2 = p.default2
      v.option3 = p.default3
      v.status  = 'Active'
      v.save
      resp.refresh = true
      render :json => resp
    end
886382
def get_version_by_version_id(version_id):
    
    for ver in registry.version_info:
        if ver.version_id == version_id:
            return ver.id

    return None
1267938
def product_requests_button(page, page_perms, is_parent=False):
    
    # Is this page the 'product' model?
    # It is generally safe to assume either the page will have a 'variants'
    #  member or will be an instance of longclaw.utils.ProductVariant
    if hasattr(page, 'variants') or isinstance(page, ProductVariant):
        yield widgets.PageListingButton(
            'View Requests',
            reverse('productrequests_admin', kwargs={'pk': page.id}),
            priority=40
        )
1010847
def find_cart_items(options)
			conditions = {:resource_id => nil, :parent_id => nil}
			conditions[:resource_id] = options[:resource].id.to_s if options[:resource]
			Auth.configuration.cart_item_class.constantize.where(conditions)
		end