Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2. class mstoFilters extends mse2FiltersHandler{
  3.  
  4. public function getMstoValues(array $fields, array $ids){
  5. $this->modx->getService('msto', 'msto', $this->modx->getOption('msto_core_path', null, $this->modx->getOption('core_path') . 'components/msto/') . 'model/msto/');
  6. $filters = array();
  7. $q = $this->modx->newQuery('mstoOffer');
  8. $q->where(array(
  9. 'product_id:IN' => $ids,
  10. ));
  11. $q->select('product_id,' . implode(',', $fields));
  12. $tstart = microtime(true);
  13. if ($q->prepare() && $q->stmt->execute()) {
  14. $this->modx->queryTime += microtime(true) - $tstart;
  15. $this->modx->executedQueries++;
  16. while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
  17. foreach ($row as $k => $v) {
  18. $v = trim($v);
  19. if ($v == '' || $k == 'product_id') {
  20. continue;
  21. } else if (isset($filters[$k][$v])) {
  22. $filters[$k][$v][] = $row['product_id'];
  23. } else {
  24. $filters[$k][$v] = array($row['product_id']);
  25. }
  26. }
  27. }
  28. } else {
  29. $this->modx->log(modX::LOG_LEVEL_ERROR, "[mSearch2] Error on get filter params.\nQuery: " . $q->toSql() . "\nResponse: " . print_r($q->stmt->errorInfo(), 1));
  30. }
  31. return $filters;
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement