Returns an array of user voting data for the given user(s)
@param integer $product_id
@param integer|array $user_id
@return array
181238
public function getByUser($product_id, $user_id)
    {
        $result = null;
        $this->hook->attach('rating.get.user.before', $product_id, $user_id, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $user_ids = (array) $user_id;
        $conditions = array_merge($user_ids, array($product_id));
        $placeholders = rtrim(str_repeat('?,', count($user_ids)), ',');

        $sql = "SELECT * FROM rating_user WHERE user_id IN($placeholders) AND product_id=?";

        $result = $this->db->fetchAll($sql, $conditions, array('index' => 'user_id'));

        if (!is_array($user_id) && isset($result[$user_id])) {
            $result = $result[$user_id];
        }

        $this->hook->attach('rating.get.user.after', $product_id, $user_id, $result, $this);
        return $result;
    }
925070
public function listProductClassField($product_class_id)
    {
        $this->setProductClassProductClassField($product_class_id);
        $this->setTitleListProductClassField();
        $this->setBreadcrumbListProductClassField();
        $this->setFilterListProductClassField();

        $this->setData('field_types', $this->field->getTypes());
        $this->setData('fields', $this->getListProductClassField());
        $this->setData('product_class', $this->data_product_class);

        $this->submitListProductClassField();
        $this->outputListProductClassField();
    }
776976
public static function loadUserInfoBypass($user_id)
    {
        global $CFG, $PDOX, $CONTEXT;
        $cacheloc = 'lti_user';
        $row = Cache::check($cacheloc, $user_id);
        if ( $row != false ) return $row;
        $stmt = $PDOX->queryDie(
            "SELECT displayname, email, user_key FROM {$CFG->dbprefix}lti_user AS U
            JOIN {$CFG->dbprefix}lti_membership AS M
            ON U.user_id = M.user_id AND M.context_id = :CID
            WHERE U.user_id = :UID",
            array(":UID" => $user_id, ":CID" => $CONTEXT->id)
        );
        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
        if ( strlen($row['displayname']) < 1 && strlen($row['user_key']) > 0 ) {
            $row['displayname'] = 'user_key:'.substr($row['user_key'],0,25);
        }
        Cache::set($cacheloc, $user_id, $row);
        return $row;
    }
978092
public function listAction($productId)
    {
        $this->checkAuth(AdminResources::PRODUCT, [], AccessManager::VIEW);

        if (null !== $response = $this->checkProduct($productId)) {
            return $response;
        }

        $request = $this->getRequest();

        if ($request->query->has('id')) {
            $request->query->remove('id');
        }

        $params = array_merge(
            array(
                "limit" => 10,
                "offset" => 0,
            ),
            $request->query->all(),
            array(
                "product" => $productId,
            )
        );

        return new JsonResponse($this->getProductSaleElements($params));
    }
267582
public function set(array $product_ids)
    {
        $lifespan = $this->getCookieLifespan();
        $result = $this->request->setCookie('product_compare', implode('|', (array) $product_ids), $lifespan);

        gplcart_static_clear();
        return $result;
    }
323787
protected function controlDeleteProductCompare(array &$result, $product_id)
    {
        if (empty($result['redirect'])) {
            $segments = explode(',', $this->path());
            if (isset($segments[0]) && $segments[0] === 'compare' && !empty($segments[1])) {
                $ids = array_filter(array_map('trim', explode(',', $segments[1])), 'ctype_digit');
                unset($ids[array_search($product_id, $ids)]);
                $result['redirect'] = $segments[0] . '/' . implode(',', $ids);
            }
        }
    }
1056551
public function get_from_user_id_and_post_ids(int $userid, array $postids) {
        $alias = $this->get_table_alias();
        [$postidinsql, $params] = $this->get_db()->get_in_or_equal($postids);
        $params[] = $userid;

        $wheresql = "{$alias}.postid {$postidinsql}";
        $wheresql .= " AND {$alias}.userid = ?";
        $sql = $this->generate_get_records_sql($wheresql);
        $records = $this->get_db()->get_records_sql($sql, $params);

        return $this->transform_db_records_to_entities($records);
    }
1322328
public function getClientUser($client_id, $user_id)
    {
        $sql = 'SELECT * from %s where client_id = :client_id and user_id = :user_id';
        $sql = sprintf($sql, $this->config['client_user_table']);

        return $this->fetch($sql, compact('client_id', 'user_id'));
    }
223300
public function findOneByProductIdAndWebsite($productId, $websiteId)
    {

        // prepare the params
        $params = array(
            MemberNames::PRODUCT_ID => $productId,
            MemberNames::WEBSITE_ID => $websiteId
        );

        // load and return the product with the passed product/website ID
        $this->productWebsiteStmt->execute($params);
        return $this->productWebsiteStmt->fetch(\PDO::FETCH_ASSOC);
    }
727882
public function editProduct($product_id = null)
    {
        $this->setProduct($product_id);
        $this->setTitleEditProduct();
        $this->setBreadcrumbEditProduct();

        $this->setData('product', $this->data_product);
        $this->setData('size_units', $this->convertor->getUnitNames('size'));
        $this->setData('weight_units', $this->convertor->getUnitNames('weight'));
        $this->setData('default_currency', $this->currency->getDefault());
        $this->setData('subtract_default', $this->config->get('product_subtract', 0));
        $this->setData('classes', $this->product_class->getList(array('status' => 1)));
        $this->setData('languages', $this->language->getList(array('enabled' => true)));

        $this->submitEditProduct();

        $this->setDataFieldsEditProduct();
        $this->setDataAuthorEditProduct();
        $this->setDataRelatedEditProduct();
        $this->setDataCategoriesEditProduct();
        $this->setDataImagesEditProduct();

        $this->setJsEditProduct();
        $this->outputEditProduct();
    }
893937
public function retrieve_user_ids(string $id_option = null, string $id_user): ?array
  {
    return $this->_retrieve_ids($id_option, $id_user);
  }
848412
public function actionAdd($productId)
    {
        if (!empty($productId)) {
            if (!Yii::$app->user->isGuest) {
                $model = new FavoriteProduct();

                $model->product_id = $productId;
                $model->user_id = Yii::$app->user->id;

                if ($model->save()) {
                    if (Yii::$app->request->isAjax) {
                        return Yii::t('shop', 'You have successfully added this product to favorites.');
                    }
                    else {
                        Yii::$app->session->setFlash('success', Yii::t('shop', 'You have successfully added this product to favorites.'));
                    }
                }
                else {
                    if (Yii::$app->request->isAjax) {
                        return Yii::t('shop', 'Error has occurred.');
                    }
                    else {
                        Yii::$app->session->setFlash('error', Yii::t('shop', 'Error has occurred.'));
                    }
                }
                return $this->redirect(Yii::$app->request->referrer);
            }
            throw new ForbiddenHttpException();
        }
        else throw new NotFoundHttpException();
    }
265199
public static function delete_by_user_id($user_id = null)
	{
		if (empty($user_id))
		{
			return true;
		}

		$results = self::all()
			->whereEquals('user_id', $user_id)
			->rows();

		foreach ($results as $result)
		{
			if (!$result->destroy())
			{
				return false;
			}
		}

		return true;
	}
499496
public function createParamsForRuleQrc($product_id)
    {
        $pay = new Order($this->config->get());
        return $pay->qrcParams($product_id);
    }
748515
public function setProductId($product_id) {

        $this->checkInArray($product_id, GDAXConstants::$productIdValues);
        $this->product_id = $product_id;
        return $this;

    }
338651
public function getRoles($user_id) {
        $results = $this->find('all', array(
            'conditions' => array(
                'RequestObject.foreign_key' => $user_id,
                'RequestObject.model' => USER_MODEL
            )
        ));

        if ($results) {
            // Grab the direct parents (or roles)
            $results = $this->find('all', array(
                'conditions' => array('RequestObject.id' => Hash::extract($results, '{n}.RequestObject.parent_id'))
            ));

            // Also grab the children of the parents since the user has access to them as well
            $results = array_merge($results, $this->find('all', array(
                'conditions' => array(
                    'RequestObject.parent_id' => Hash::extract($results, '{n}.RequestObject.id'),
                    'RequestObject.model' => null,
                    'RequestObject.foreign_key' => null
                )
            )));
        }

        return $results;
    }
162653
private function getSearchableProducts($storeId, $productIds = null, $fromId = 0, $limit = 10000)
    {
        return $this->resourceModel->getSearchableProducts($storeId, $productIds, $fromId, $limit);
    }