Data from Tables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Data from Tables

mandeepmavi
Hi, Want to know how I can fetch or get data from a Table.
Need some first basic steps.
I tried, but have no idea where is mistake.
Want to start from step one.

I am able to take data from table which is already in use. But not from other.

In my case i want to take data (id_value) from table good_identification.

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Data from Tables

mandeepmavi
Hi friends,
Unable to work with database. Need some reference or Guide to get data from table. I tried lots nothing working for me.

otherwise if some one explain me the below. How it work.


    public String getDescription() {
        GenericValue product = getProduct();

        if (product != null) {
            String description = ProductContentWrapper.getProductContentAsText(product, "DESCRIPTION", this.locale, null);

            // if the description is null or empty, see if there is an associated virtual product and get the description of that product
            if (UtilValidate.isEmpty(description)) {
                GenericValue parentProduct = this.getParentProduct();
                if (parentProduct != null) {
                    description = ProductContentWrapper.getProductContentAsText(parentProduct, "DESCRIPTION", this.locale, null);
                }
            }

            if (description == null) {
                return "";
            } else {
                return description;
            }
        } else {
            return null;
        }
    }
     
Reply | Threaded
Open this post in threaded view
|

Re: Data from Tables

mandeepmavi
Can i use something like below to retrieve id_value from Good_Identification, But this is not returning anything. Where can i get more help. Stuck to work with Tables and Delegators.  

    public GenericValue getProductUPC() {
        if (this._product != null) {
            return this._product;
        }
        if (this.productId != null) {
            try {
                this._product = this.getDelegator().findOne("GoodIdentification", UtilMisc.toMap("productId", productId), true);
            } catch (GenericEntityException e) {
                throw new RuntimeException("Entity Engine error getting Product (" + e.getMessage() + ")");
            }
        }
        return this._product;
    }


and



        public String getUpcID() {
        GenericValue product = getProductUPC();
   
        if (product != null) {
       
        String idvalue = ProductContentWrapper.getProductContentAsText(product, "id_value", this.locale, null);

            // if the description is null or empty, see if there is an associated virtual product and get the description of that product

            if (idvalue == null) {
                return "";
            } else {
                return idvalue;
            }
        } else {
            return null;
        }
        }