Check if a rule is passed in Cart rules - shopware

I can see the rules applied to a cart with
CheckoutCartPageLoadedEvent
$event->getPage()->getCart()->getRuleIds()
but how can I know if a certain rule passed or not? For what I understand the RuleIds array contains all the rules evaulated, but I can't see if they are passed or not.

Both ruleIds list properties retrieved from either the current Context object or the current Cart object should only contain the ids of rule entities that evaluated to true. If an id is included, the rule's conditions were met, otherwise they weren't.

Related

Shopware6 : How to create rules for custom field in order

My goal is to achieve something like the following with flowbuilder:
Trigger: order placed (achievable with the flowbuilder)
If : if order.customFields.customtextField not empty (trying to implement this)
Action : send email with (achievable with the flowbuilder)
For this, I am trying to add a custom rule for order following this : https://developer.shopware.com/docs/guides/plugins/plugins/framework/rule/add-custom-rules#create-custom-rule
But, I see that the last created order is not easily accessible in the rule class. Is there a better/recommended way to do check for an order custom field after order is placed?
Within the flow the order is converted back to a cart with the order line items becoming cart line items once again. This is done to make existing rules work for both evaluating carts and orders. This also means the custom fields of a placed order are not available in the context of the cart as they wouldn't be available yet during checkout. Unfortunately within a rule condition there is no ideal way to identify if the cart was converted from an existing order, no less which order it is.
What you could do however is add a new flow action. Within the scope of the action you could have access to the order entity and then decide within the action what to do with it. The triggers for order placed or enter/leave states will dispatch CheckoutOrderPlacedEvent or OrderStateMachineStateChangeEvent respectively. Both of these have a getter for the order entity which you will be able to access from within your action.
public function handle(FlowEvent $event): void
{
$baseEvent = $event->getEvent();
if (!$baseEvent instanceof CheckoutOrderPlacedEvent && !$baseEvent instanceof OrderStateMachineStateChangeEvent) {
return;
}
$order = $baseEvent->getOrder();
// evaluate the order and decide what to do with it
}
I see that another approach that worked for me was with adding a custom trigger(event) which is dispatched when checkout.order.placed event is fired and if that event's order has the custom field that I am looking for.

Jmeter For each Controller

I've created in Jmeter the follwing:
HTTP Request (first one)
(Regular Expression Extractor) for the Response Body (I set the name of the variable, and put the correct regular expression,which works fine and returns the searched pattern)
(ForEach Controller) to iterate the Array (and of course I put the name of the array variable, and the ouput variable name (index))
another subsequent Http Request under (ForEach Controller Level) (then I put the value index of the array on the path like: /${smalpl_index}
Now I expect the second http Request below the (ForEach Controller) make a new Request based on the index Element of the Array from the Regular Expression, however I got null on the request...(see below)
Hier you find all the screenshot of the test scenario:
https://imgur.com/a/Eqbk9Mx#cp5raNc
GET http://edge.flowplayer.org/null
I see only one request in your screenshot and my expectation is that you should have at least one passed HTTP Request (first one)
In the Regular Expression Extractor make sure to set "Match No." to -1
Add Debug Sampler after the HTTP Request (first one) and make sure it contains the variables you're looking for, in order for ForEach Controller to work you need to have the following variables pattern:
var_1=some value
var_2=some other value
etc.
Check out Using Regular Expressions in JMeter article for example of extracting all links from the page and opening them via ForEach Controller.
Also for the majority of HTML responses using Regular Expressions is not the best idea, it might be better to consider CSS Selector Extractor
The problem was in the regular expression template,since I'm searching for the entire pattern , I should not put $1$, instead of $0$,because $1$ means the second group number, and in my case I have one group, and so it works fro me...

Maximo crossover domain

In Workorder tracking , there is a field "LEAD" which will display ID of lead.
In our requirement we have to display Leadname along with Lead ID.
SO I created a new field for Leadname in Workorder and used crossover domain with a new relation between Wordorder and Person. Relation where clause being personid=:lead
The crossover domain copies over the value of Leadname from Displayname attribute of PERSON object and is working fine when we give an ID in Lead attribute of Workorder.
However in case if I give a Lead ID and then remove the lead ID in WO , then leadname still remains It doesnt get modified to null.
I believe its because the crossover condition (personid=:lead ) is not satisfied and hence no action is being performed. I tried setting condition on Source and Destination as well but that also is not working.
Is there any way to default a field to null in case if crossover where clause condition is not met.
I was able to get this implemented by using automation script , but would like to know whether same can be achieved by some other means.
If it is just displaying the information you should use a multipart textbox to show lead and displayname of the person. You need to add a relation from workorder to person using the lead attribute. Then normal Maximo logic will clear the 'description' when you clear the actual lead field.
There is a way to cross-over fixed values, including null, to clear another field on a crossover action. Just make an ALNDOMAIN with a empty value (leave description empty) In the crossover domain use a relation that points to this specific domain/value and use dot-notation to crossover the description. Use relationname.description as the sourcefield in your crossover
RFE 72680 / crossovers, option to set targets to null or default value when trigger field becomes null is intended to address this shortfall in functionality. Please cast your vote!

Ldap Query to return sub tree only if parent condition is true

I'm trying to write a search filter that return results of a sub tree, only if the parent tree meets certain condition... is it possible?
I have the following structure:
ou=ftp
domainName=example.com
ou=users
uid=firstUser
uid=secondUser
domainName=otherdomain.com
ou=users
uid=othertUser
uid=otherdUser
In domainName=example.com I have an atrribute accountStatus that can be "active" or "inactive".
I want to return the users only if accountStatus is "active".
I tried to do a composite filter as follows:
(&(&(objectclass=mailDomain)(accountStatus=active))(&(uid=*)(objectclass=posixAccount)))
objectclass=mailDomain and accountStatus=active belongs to the parent tree.
The query does not return any results, because it search all the attributes at the same level.
Thank you for your help.
While you can configure the search space to be a subtree, a list or even a single entry, a search filter is always applied to each single entry of the result set. This usually influences the design of the directory information tree, and the schema as well.
Stay away from "normalization" and make attributes available at the user entry instead of some parent node. You greatly increase the overall value of your directory that way, allowing simple LDAP clients to leverage the information in your directory.

Orchard CMS - Query based on values from ContentPicker

EDIT: Rephrased issue
I think there is either a bug or I am doing something wrong.
I add a field to the type Blogpost. This field is of type
Contentpicker. I call it Related Page.
Then I create to regular pages (ContentType Page).
I create 4 blogposts. Two blogposts get PageOne as selected value in the RelatedPage field. The other two posts get PageTwo as selected value in the RelatedPage.
Now I create a query with filter ContentType is BlogPost. And a filter with Blog Post.Related Page equals {21} (that is the Id of PageOne).
I would expect to get results BlogPostOne and BlogPostTwo. Instead I don't get results. Actually I wanted the pageid to be retrieved from the page the widget is placed on but couldn't get it to work, so I reduced back to a predefined value instead of dynamic for the filter. But like I said no results.
So is the query wrong and how should I do it then. Or is there a bug with filters for ContentPicker fields.
P.S. I will also submit an issue in Codeplex.
UPDATE
In Tokenizer all the values that contain { } are being seen as tokens and therefore are replaced. The problem is that the Ids of content items in a contentpicker field are stored with accolades. So when having {21} as the value for the filter, 21 gets tokenized and since there is no value for this token the value becomes empty. When skipping the tokenizer it works (while debugging). But one cannot skip the tokenizer, because it is very legitimate that there is a token present.
So I believe there is a bug with either the tokenizer, or the way the ids are stored in the contentitem field for contentpicker. I think it can be solved by changing the contentpicker to store numbers separated with comma's but without the accolades.
have you tried using the alias of the page instead of content id as the identifier? e.g. "/about-us", like you do in the layer rules.

Resources