Magento: Retrieve a list of Groups from a Attribute Set - magento

I need to retrive a list of all groups of a certain attribute Set, given by the ID or name for example via API.
To do so, I've checked the API here (http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/productAttributeSet.html) but it seems there's no way to list groups, only create, update and delete is possible.
What can I do to get the id of a certain group?
Thanks.

MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.catalogProductAttributeGroupRepositoryV1PortTypeClient mage_client= AttributeGroup;
MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.CatalogProductAttributeGroupRepositoryV1GetListRequest nn = new MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.CatalogProductAttributeGroupRepositoryV1GetListRequest();
MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkFilter filter = new MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkFilter();
MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkFilter[] filters = new MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkFilter[1];
filter.field = "attribute_set_id";
filter.value = "31";
filter.conditionType = "eq";
filters[0] = filter;
//MNC_Product_Sync.MagentoService.FrameworkFilter filter1 = new MNC_Product_Sync.MagentoService.FrameworkFilter();
MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkSearchFilterGroup fg = new MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkSearchFilterGroup();
fg.filters = filters;
MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkSearchFilterGroup[] fgg = new MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkSearchFilterGroup[1];
fgg[0] = fg;
MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkSearchCriteriaInterface search = new MNC_Product_Sync.catalogProductAttributeGroupRepositoryV1Service.FrameworkSearchCriteriaInterface();
search.filterGroups = fgg;
search.pageSize = 100;
nn.searchCriteria = search;
try
{
var response = mage_client.catalogProductAttributeGroupRepositoryV1GetList(nn);
}

Related

web api - list all data types on a class

I'm trying to list all the data types on a class and after give the information to a client
i know that i have to use the GetType. So here is what i have at the moment
var variables = typeof(MockClass).GetType()
.Select(field => field.Name) //error: 'Type' does not contain a definition for select
.ToList();
I'm trying to enter inside the class, use a query to select all the variables name and try to get their data type.. Any ideas?
Try this
var type = typeof(MockClass);
var nestedTypes = new List<Type>();
var typeNames = new List<string>();
var propertiesNames = new List<string>();
foreach(var p in type.GetProperties())
{
var t = p.PropertyType;
nestedTypes.Add(t);
typeNames.Add(t.Name);
propertiesNames.Add(p.Name);
}

Is Dynamics CRM 2013 sdk cache result of QueryExpresions by Default?

I wrote this simple query:
var connectionString = String.Format("Url={0}; Username={1}; Password={2}; Domain={3}", url, username, password, domain);
var myConnection = CrmConnection.Parse(connectionString);
CrmOrganizationServiceContext _service = new CrmOrganizationServiceContext(myConnection);
var whoAmI = _service.Execute(new WhoAmIRequest());
var query = new QueryExpression
{
EntityName = "phonecall",
ColumnSet = new ColumnSet(true)
};
query.PageInfo = new PagingInfo
{
Count = 20,
PageNumber = 1,
PagingCookie = null
};
query.Orders.Add(new OrderExpression
{
AttributeName = "actualstart",
OrderType = OrderType.Descending
});
query.Criteria = new FilterExpression() { FilterOperator = LogicalOperator.And };
query.Criteria.AddCondition("call_caller", ConditionOperator.In, lines);
var entities = _service.RetrieveMultiple(query).Entities;
I have a program which runs this query every minute. On the first execution the correct results are displayed but for subsequent queries the results never change as I update records in CRM.
If I restart my program the results refresh correctly again on the first load.
Why are the results not updating as records are modified in CRM?
It is the CrmOrganizationServiceContext that is doing the caching - I found the following worked a treat and the results of my RetrieveMultiple are no longer cached :)
Context = new CrmOrganizationServiceContext(CrmConnection.Parse(connectionString));
Context.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
RetrieveMultiple always brings back fresh results so there must be some other aspect of your program which is causing stale data to be displayed.

How to create a predicate that must meet two values with one being a list of values?

With the following code how do I get a return that includes any of zip list but only records that have a purpose of street address? This currently returns matches for either the zip or the street address.
var zipPredicate = PredicateBuilder.False<NameAddress>();
List<string> zips = new List<string>();
zips.Add("90210");
zips.Add("90211");
foreach (var item in zips)
{
zipPredicate = zipPredicate.Or(n=> n.ZIP.Contains(item));
}
zipPredicate = zipPredicate.And(n=> n.Purpose=="Street Address");
var zipResult = from s in NameAddresses
.AsExpandable()
.Where(zipPredicate)
select new{s.ID, s.ZIP, s.Purpose};
zipResult.Dump();
I think what you are looking for is:
var zipPredicate = PredicateBuilder.False<NameAddress>();
List<string> zips = new List<string>();
zips.Add("90210");
zips.Add("90211");
foreach (var item in zips)
{
zipPredicate = zipPredicate.Or(n=> n.ZIP.Contains(item) && n.Purpose=="Street Address");
}
var zipResult = from s in NameAddresses
.AsExpandable()
.Where(zipPredicate)
select new{s.ID, s.ZIP, s.Purpose};
zipResult.Dump();
EDIT
One more thing as well, if you want to drop building up the predicate, you should be able to do something like: .Where(n=>zips.Contains(n.ZIP) && n.Purpose=="Street Address") The important piece is that your entity property component comes inside the .Contains(). This would shorten your code to:
List<string> zips = new List<string>();
zips.Add("90210");
zips.Add("90211");
var zipResult = from s in NameAddresses
.AsExpandable()
.Where(n=>zips.Contains(n.ZIP) && n.Purpose=="Street Address")
select new{s.ID, s.ZIP, s.Purpose};
zipResult.Dump();
Which I like better for readability. I would expect the query that ends up getting executed is the same either way.

Retrieving related entities using RetrieveMultipleRequest

I have an entity called Invoice and an entity called InvoiceItem.
There is a one to many relationship called new_invoice_invoiceitem.
There is a LookupAttribute in InvoiceItem called new_parent_invoice_invoiceitem.
I am trying to retrieve the InvoiceItems that are related to the Invoice with a particular ID using the following code:
QueryExpression query = new QueryExpression();
query.EntityName = "new_invoiceitem";
query.ColumnSet = new AllColumns();
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "new_parent_invoice_invoiceitem";
condition.Values = new object [] { new Guid("fe1009cc-e034-49d5-bc59-ab4c3091a6f9") };
condition.Operator = ConditionOperator.Equal;
FilterExpression filter = new FilterExpression();
filter.AddCondition(condition);
query.Criteria = filter;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);
BusinessEntityCollection bec = response.BusinessEntityCollection;
The code runs without errors but the BusinessEntityCollection is always empty even though there are records in Dynamics.
Any idea what I'm doing wrong?
Thanks,
David
Try setting request.ReturnDynamicEntities = true

Problem In Updating the existing record in subsonic 3.0

private Boolean Saveuser(bool isNew)
{
tb_User user = new tb_User();
user.User_Name = txtUserName.Text.Trim();
user.User_LoginName = txtLoginName.Text;
user.User_Password = txtPassord.Text;
user.User_ModifiedBy = clsGlobalVariable.strusername;
user.User_Modified = DateTime.Now;
user.User_IsDeleted = false;
user.User_IsUpdated = true;
user.User_UserGroup = "";
user.User_UserType = "";
user.User_WarehouseCode = "";
user.SetIsNew(isNew);
user.Save();
}
when I try to insert new user using above coding, it is worik, but try to update existing user by passing isNew (false). It is not working, when I trace inside activerecord.cs, the dirty column count is always 0 for both new and update. How can I update the existing record?
Please answer for me?
Thanks.
You should
Get the record
Update record
Save
User u = User.FetchByID(2345);
u.User_Name = "blablabla";
//other User object modifications...
u.Save();

Resources