Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.2
Component:
Rules integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Feb 2012 at 14:16 UTC
Updated:
14 Sep 2013 at 15:43 UTC
I am using Feeds to import products and product displays. Because I am working on multiple sites with one CSV file, I need to create a rule to make sure that one cannot view a product display if it has not referenced products.
I am thinking about creating a rule on Node creation or update with a condition for the product reference field. If empty, it would unpublish the product display. However, I'm not familiar with rules to know how to do this.
Is this the correct way? Any better ideas? Suggestions?
Comments
Comment #1
liupascal commentedSomething like this :
Rule event :
- Node creation
- Node update
Rule condition :
1- entity has field
--> product reference field
2- field is empty on the product reference field
Rule action :
- unpublish node
Comment #2
rtdean93 commentedThanks for the suggestion...
Since the Referenced Product is required, just checking to see if it was empty was not enough. In fact, the rule could not fire since I could not create or update a blank field. (the only way a field could be empty is if we use feeds to import product displays without the related products).
So instead, I created a view to show all of the related products attached to a node. Then I used a rule to count the results of the view. If the view was blank, then the rule would unpublish the product display.
Here is the view...
Here is the rule...
Comment #3
rszrama commentedMarking this fixed. Glad to see you got a solution.
Comment #4
liupascal commentedYou could also have looped over the list of products and checked each status with rule component.
Comment #6
summit commentedHi,
How to handle this when you have multiple views which show product-displays?
Greetings, Martijn