Return's the URL rewrite product category relation for the passed
URL rewrite ID.

@param integer $urlRewriteId The URL rewrite ID to load the URL rewrite product category relation for

@return array|false The URL rewrite product category relation
342781
public function load($urlRewriteId)
    {

        // initialize the parameters
        $params = array(MemberNames::URL_REWRITE_ID => $urlRewriteId);

        // load and return the URL rewrite product category relation
        $this->urlRewriteProductCategoryStmt->execute($params);
        return $this->urlRewriteProductCategoryStmt->fetch(\PDO::FETCH_ASSOC);
    }
952574
public function getPinnedByCategoryId( $categoryId, $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$config[ 'page' ]	= isset( $config[ 'page' ] ) ? $config[ 'page' ] : false;
		$config[ 'query' ]	= isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::find();
		$config[ 'limit' ]	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10;
		$config[ 'active' ]	= isset( $config[ 'active' ] ) ? $config[ 'active' ] : true;

		if( $config[ 'active' ] ) {

			$config[ 'query' ]->joinWith( 'activeCategories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] );
		}
		else {

			$config[ 'query' ]->joinWith( 'categories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] );
		}

		if( $config[ 'page' ] ) {

			$page	= $this->getPublicPage( $config );

			return $page->getModels();
		}

		return $config[ 'query' ]->limit( $config[ 'limit' ] )->all();
	}
785993
public static function linkUrl($pageId, $pageUrl)
    {
        if (self::$pages === null) {
            self::initPages();
        }

        if ($pageUrl) {
            if (strpos($pageUrl, 'http') === 0) {
                return Url::to($pageUrl);
            }

            return Url::to([$pageUrl]);
        }

        if (isset(self::$pages[$pageId]['link'])) {
            if (self::$pages[$pageId]['link']) {
                return Url::to(['/' . self::$pages[$pageId]['link']]);
            }
        }

        return Url::home();
    }
723083
public function actionList(int $productId, int $languageId)
    {

        $product = Product::findOne($productId);
        $products = Product::find()->joinWith('translations')->orderBy('title')->all();
        $relatedProducts = $product->relatedProducts;
        $newRelatedProduct = new RelatedProduct();

        $selectedLanguage = Language::findOne($languageId);
        $languages = Language::find()->all();

        if (\Yii::$app->request->isPost && $newRelatedProduct->load(\Yii::$app->request->post())) {
            if (empty(RelatedProduct::find()
                ->where(['product_id' => $productId, 'related_product_id' => $newRelatedProduct->related_product_id])->one())
            ) {

                $newRelatedProduct->product_id = $productId;
                if ($newRelatedProduct->validate()) $newRelatedProduct->save();
                \Yii::$app->session->setFlash('info', \Yii::t('shop', 'Relation product has added successfully'));
            } else {
                \Yii::$app->session->setFlash('info', \Yii::t('shop', 'Such relation product already exists for this product'));
            }

            return $this->redirect(\Yii::$app->request->referrer);
        }

        return $this->render('../product/save', [
            'viewName' => '../related-product/list',
            'selectedLanguage' => $selectedLanguage,
            'product' => $product,
            'languages' => $languages,

            'params' => [
                'product' => $product,
                'products' => $products,
                'relatedProducts' => $relatedProducts,
                'newRelatedProduct' => $newRelatedProduct,
                'languages' => $languages,
                'selectedLanguage' => $selectedLanguage,
            ]
        ]);
    }
1187336
public static function reconstructNormalizedUrl($url, $prefixId)
    {
        $map = array_flip(self::$urlPrefixMap);

        if ($prefixId !== null && isset($map[$prefixId])) {
            $fullUrl = $map[$prefixId] . $url;
        } else {
            $fullUrl = $url;
        }

        // Clean up host & hash tags, for URLs
        $parsedUrl = @parse_url($fullUrl);
        $parsedUrl = PageUrl::cleanupHostAndHashTag($parsedUrl);
        $url       = UrlHelper::getParseUrlReverse($parsedUrl);

        if (!empty($url)) {
            return $url;
        }

        return $fullUrl;
    }
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();
    }
169740
public function getRewritesAsArray()
    {

        // initialize the array for the rewrites
        $rewrites = array();

        // prepare the array with the rewrite rules
        /** @var \AppserverIo\Appserver\Core\Api\Node\RewriteNode $rewrite */
        foreach ($this->getRewrites() as $rewrite) {
            // rewrites might be extended using different injector extension types, check for that
            if ($rewrite->hasInjector()) {
                $target = $rewrite->getInjection();
            } else {
                $target = $rewrite->getTarget();
            }

            // build up the array entry
            $rewrites[] = array(
                'condition' => $rewrite->getCondition(),
                'target' => $target,
                'flag' => $rewrite->getFlag()
            );
        }

        // return the array
        return $rewrites;
    }
1282207
static function updateUrlObjectLinks( $contentObjectAttribute, $urlIDArray )
    {
        $objectAttributeID = $contentObjectAttribute->attribute( 'id' );
        $objectAttributeVersion = $contentObjectAttribute->attribute('version');

        // Ensure links that have been removed from the attribute version are removed from the object link table
        $linkObjectLinkList = eZURLObjectLink::fetchLinkObjectList( $objectAttributeID, $objectAttributeVersion );
        foreach ( $linkObjectLinkList as $linkObjectLink ) {
            if ( !in_array( $linkObjectLink->attribute( 'url_id' ), $urlIDArray ) ) {
                $linkObjectLink->remove();
            }
        }

        // Ensure links that have been added to the attribute version are added to the object link table
        foreach( $urlIDArray as $urlID )
        {
            $linkObjectLink = eZURLObjectLink::fetch( $urlID, $objectAttributeID, $objectAttributeVersion );
            if ( $linkObjectLink == null )
            {
                $linkObjectLink = eZURLObjectLink::create( $urlID, $objectAttributeID, $objectAttributeVersion );
                $linkObjectLink->store();
            }
        }
    }
1074829
public function deleteURLWildcard($urlWildcardId)
    {
        $this->urlWildcardService->remove(
            $this->urlWildcardService->load($urlWildcardId)
        );

        return new Values\NoContent();
    }
522141
public function fetchData($storeId = Store::DEFAULT_STORE_ID, $categoryIds = [])
    {
        $connection = $this->getConnection('read');
        $table = $this->getTable('url_rewrite');
        $select = $connection
            ->select()
            ->from($table, ['entity_id', 'request_path'])
            ->where('entity_type = ?', 'category')
            ->where('redirect_type = ?', 0)
            ->where('store_id = ?', $storeId)
            ->where('entity_id IN (' . implode(',', $categoryIds) . ')');

        return $connection->fetchPairs($select);
    }
1010581
public function getRedirectList($siteId)
    {
        try {
            $result = $this->getQuery($siteId)->getResult();
        } catch (NoResultException $e) {
            $result = [];
        }

        return $result;
    }
248318
protected function getCategoryProductSelect($productIds, $storeId)
    {
        $select = $this->getConnection()->select()
            ->from(['cpi' => $this->getTable($this->getCategoryProductIndexTable($storeId))])
            ->where('cpi.store_id = ?', $storeId)
            ->where('cpi.product_id IN(?)', $productIds);

        return $select;
    }
818285
public static function fetch_course_category($courseid) {
        if (empty($courseid)) {
            debugging('Missing course id!');
            return false;
        }

        // course category has no parent
        if ($course_category = grade_category::fetch(array('courseid'=>$courseid, 'parent'=>null))) {
            return $course_category;
        }

        // create a new one
        $course_category = new grade_category();
        $course_category->insert_course_category($courseid);

        return $course_category;
    }
516466
protected function initializeUrlRewrite(array $attr)
    {

        // load the category ID of the passed URL rewrite entity
        $categoryId = $this->getCategoryIdFromMetadata($attr);

        // iterate over the available URL rewrites to find the one that matches the category ID
        foreach ($this->existingUrlRewrites as $urlRewrite) {
            // compare the category IDs AND the request path
            if ($categoryId === $this->getCategoryIdFromMetadata($urlRewrite) &&
                $attr[MemberNames::REQUEST_PATH] === $urlRewrite[MemberNames::REQUEST_PATH]
            ) {
                // if a URL rewrite has been found, do NOT create OR keep an existing redirect
                $this->removeExistingUrlRewrite($urlRewrite);

                // if the found URL rewrite has been created manually
                if ((integer) $urlRewrite[MemberNames::IS_AUTOGENERATED] === 0) {
                    // do NOT update it nor create another redirect
                    return false;
                }

                // if the found URL rewrite has been autogenerated, then update it
                return $this->mergeEntity($urlRewrite, $attr);
            }
        }

        // simple return the attributes
        return $attr;
    }
436706
public function attachment_link( $link, $post_id ) {
		/**
		 * WP_Rewrite.
		 *
		 * @var WP_Rewrite $wp_rewrite
		 */
		global $wp_rewrite;

		if ( ! $wp_rewrite->permalink_structure ) {
			return $link;
		}

		$post = get_post( $post_id );
		if ( ! $post->post_parent ) {
			return $link;
		}

		$post_parent = get_post( $post->post_parent );
		if ( ! $post_parent ) {
			return $link;
		}

		$pt_object = get_post_type_object( $post_parent->post_type );

		if ( empty( $pt_object->rewrite ) ) {
			return $link;
		}

		if ( ! in_array( $post->post_type, CPTP_Util::get_post_types(), true ) ) {
			return $link;
		}

		$permalink   = CPTP_Util::get_permalink_structure( $post_parent->post_type );
		$post_type   = get_post_type_object( $post_parent->post_type );

		if ( empty( $post_type->_builtin ) ) {
			if ( strpos( $permalink, '%postname%' ) < strrpos( $permalink, '%post_id%' ) && false === strrpos( $link, 'attachment/' ) ) {

				$link = str_replace( $post->post_name, 'attachment/' . $post->post_name, $link );
			}
		}

		return $link;
	}
1026101
public function findByAttributeIdAndProductId($attributeId, $productId)
    {
        try {
            $queryBuilder = $this->createQueryBuilder('productAttribute')
                ->leftJoin('productAttribute.attribute', 'attribute')
                ->leftJoin('productAttribute.product', 'product')
                ->andWhere('attribute.id = :attributeId')
                ->andWhere('product.id = :productId')
                ->setParameter('attributeId', $attributeId)
                ->setParameter('productId', $productId);

            return $queryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
466718
public function isUrlRewritingEnabled()
    {
        $urlRewritingEnabled = $this->getConfig('rewrite_url');
        if ($urlRewritingEnabled !== null) {
            return $urlRewritingEnabled;
        }

        if (isset($_SERVER['PICO_URL_REWRITING'])) {
            $this->config['rewrite_url'] = (bool) $_SERVER['PICO_URL_REWRITING'];
        } elseif (isset($_SERVER['REDIRECT_PICO_URL_REWRITING'])) {
            $this->config['rewrite_url'] = (bool) $_SERVER['REDIRECT_PICO_URL_REWRITING'];
        } else {
            $this->config['rewrite_url'] = false;
        }

        return $this->config['rewrite_url'];
    }