A
A
Alex Teterin2014-11-27 14:27:14
Drupal
Alex Teterin, 2014-11-27 14:27:14

Who knows how to make this software filter for Views?

This is a question for real gurus.
ca600dbaabfa4fc28240392bab412a51.png
1. There is a product type node
2. The product has a multiple field "Offer" (Anton 100 rubles. Igor - 200 rubles), that is, Anton offers this product for 100, Igor for 200. The multiple field has 2 fields, respectively - Name and Price.
3. Views gives a filter in the form of a field in which we simply enter the name of several products separated by a space “Bread Points”
4. Views gives a list of all offers for these products:
Bread - 100 rubles
Bread - 200 rubles
Glasses - 15 rubles
Points - 60 rubles
QUESTION:
How can I make views display one offer with the lowest price for each product?
Bread - 100 rubles
Points - 15 rubles

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2014-12-06
@errogaht

I warn you in advance that I am answering a question not posed. The solution is purely code and not for Views. But maybe someone will come in handy.

$searchString = "Хлеб Очки";
$searchArrray = explode(" ",$searchString);
$searchNids = array();
foreach($searchArray => $itemTitle) {
  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type','node')
    ->entityCondition('bundle','YOUR_NODE_TYPE')
    ->propertyCondition('title', $itemTitle ,'LIKE')
    ->fieldOrderBy('field_PRICE','value','ASC')
    ->range(0,1);
  $result = $query->execute();

  if(!empty($result['node'])){
    $searchNids[] = array_keys($result['node']);
  }
})

Ultimately, the searchNids array will store the IDs of the nodes you need. With a minimum price and in the singular. Only they still have to be loaded via node_load_multiple();
Something like this. If not right, please correct me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question