6

I am trying to get all the promotions created for a page. I am using the below code:

QueryBuilder querybuilder = new QueryBuilder("catalog01", "en-US", puburi, regions);
querybuilder.addCriteria(new PageCriteria("1-1-64"));

ResultSet results = querybuilder.execute();

Above code is returning empty value for results.getPromotions(). Perhaps I can assume promotions are created based on some trigger, so to get the promotions I am required to pass the Triggers as a claim. Can anyone suggest if it a correct assumption. If yes, Is there a way to get all the promotions created for a particular page. I can get Items with results.getItems(), but that is all the items published in the fredhopper.

5

The SmartTarget query in your question does not add any trigger values and terefore you will only get those promotions which have no triggers.

While it is a good idea to make a test promotion without triggers you also have to use the AmbientDataHelper to get the triggers.

// get the triggers from ADF
ClaimStore claimStore = AmbientDataContext.CurrentClaimStore;
string triggers = AmbientDataHelper.GetTriggers(claimStore);

// make  query builder and feed the triggers into it
var queryBuilder = new QueryBuilder();
queryBuilder.Parse(triggers);

source

  • 1
    Test with a promotion with no triggers, hand picked component and do not use "include child publications" option on the SmartTarget promotion. – Jan H Aug 14 '15 at 15:37
  • Hi Jan, Thanks for your response. Actually, I need all the promotions created for a page, that's why I have not added any trigger in my query. Is there any way to get the promotions created for a page or component used to create the promotion for the page? I have a requirement to provide option to editor to update all promotions available on a page in a single attempt.. – Mukesh Kumar Aug 14 '15 at 17:39
  • 1
    If you need promotions for a page you indeed add PageCriteria like in the code from your question. Getting all promotions is only possible if the promotions do not have triggers. That is because SmartTarget will only return promotions which match the criteria, including triggers. – Jan H Aug 14 '15 at 18:58
  • 1
    If you need to retireve promotions for editorial needs you should not use this part of the APIs, the SmartTarget query is for content delivery (the website). For editorial needs you could retrieve the promotions from the Content Delivery Web Service, that would retrieve a list of all promotions though, not for a specific page. – Jan H Aug 14 '15 at 19:03
  • 2
    Hi Jan, Thanks for your response. Your response is good to understand some limitation of smart target API and its use cases. So I am marking your response as an answer of my question. Unfortunately page criteria is also not working for me. For this issue I have asked a separate question with url tridion.stackexchange.com/questions/12648/…. If you have any idea about that question please share.. – Mukesh Kumar Aug 16 '15 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.