From 4f834f8a053d9818074ba66a0490a25074726fae Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 16 Jul 2007 03:23:23 +0000 Subject: [PATCH] [ 1754540 ] Add attribute instance retrieval method to MProduct --- base/src/org/compiere/model/MProduct.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/base/src/org/compiere/model/MProduct.java b/base/src/org/compiere/model/MProduct.java index 01f62a2891..f8d3bc89a0 100644 --- a/base/src/org/compiere/model/MProduct.java +++ b/base/src/org/compiere/model/MProduct.java @@ -710,5 +710,26 @@ public class MProduct extends X_M_Product delete_Tree(X_AD_Tree.TREETYPE_Product); return success; } // afterDelete + + /** + * Get attribute instance for this product by attribute name + * @param name + * @param trxName + * @return + */ + public MAttributeInstance getAttributeInstance(String name, String trxName) { + MAttributeInstance instance = null; + + MTable table = MTable.get(Env.getCtx(), MAttribute.Table_ID); + MAttribute attribute = (MAttribute)table.getPO("Name = ?", new Object[]{name}, trxName); + if ( attribute == null ) return null; + table = MTable.get(Env.getCtx(), MAttributeInstance.Table_ID); + instance = (MAttributeInstance)table.getPO( + MAttributeInstance.COLUMNNAME_M_AttributeSetInstance_ID + "=?" + + " and " + MAttributeInstance.COLUMNNAME_M_Attribute_ID + "=?" , + new Object[]{getM_AttributeSetInstance_ID(), attribute.getM_Attribute_ID()}, + trxName); + return instance; + } } // MProduct