[ 1754540 ] Add attribute instance retrieval method to MProduct

This commit is contained in:
Heng Sin Low 2007-07-16 03:23:23 +00:00
parent 2fa23e9193
commit 4f834f8a05
1 changed files with 21 additions and 0 deletions

View File

@ -710,5 +710,26 @@ public class MProduct extends X_M_Product
delete_Tree(X_AD_Tree.TREETYPE_Product); delete_Tree(X_AD_Tree.TREETYPE_Product);
return success; return success;
} // afterDelete } // 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 } // MProduct