Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class mstoFilters extends mse2FiltersHandler{
- public function getMstoValues(array $fields, array $ids){
- $this->modx->getService('msto', 'msto', $this->modx->getOption('msto_core_path', null, $this->modx->getOption('core_path') . 'components/msto/') . 'model/msto/');
- $filters = array();
- $q = $this->modx->newQuery('mstoOffer');
- $q->where(array(
- 'product_id:IN' => $ids,
- ));
- $q->select('product_id,' . implode(',', $fields));
- $tstart = microtime(true);
- if ($q->prepare() && $q->stmt->execute()) {
- $this->modx->queryTime += microtime(true) - $tstart;
- $this->modx->executedQueries++;
- while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
- foreach ($row as $k => $v) {
- $v = trim($v);
- if ($v == '' || $k == 'product_id') {
- continue;
- } else if (isset($filters[$k][$v])) {
- $filters[$k][$v][] = $row['product_id'];
- } else {
- $filters[$k][$v] = array($row['product_id']);
- }
- }
- }
- } else {
- $this->modx->log(modX::LOG_LEVEL_ERROR, "[mSearch2] Error on get filter params.\nQuery: " . $q->toSql() . "\nResponse: " . print_r($q->stmt->errorInfo(), 1));
- }
- return $filters;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement