1

I am adding product links to a CMS page using the "Catalog Product Link" widget feature. The inserted code looks like such:

{{widget type="catalog/product_widget_link" title="title" template="catalog/product/widget/link/link_block.phtml" id_path="product/99"}}

The links are display with the store code at the end, such as ?___store=default. How can I remove this extra part of the url from these particular links?

I've looked at catalog/product/widget/link/link_block.phtml but I don't see where it says to display ?___store=default anywhere in the code.

NOTE: Under Add Store Code to Urls in admin, the option is selected to NO.

2 Answers 2

2

If you want to remove the __store parameter you can override Mage_Catalog_Block_Product_Widget_Link block and write the following code.

<?php

class Custom_Catalog_Block_Product_Widget_Link
    extends Mage_Catalog_Block_Product_Widget_Link
{

    /**
     * Prepare url using passed id and return it
     * or return false if path was not found.
     *
     * @return string|false
     */
    public function getHref()
    {
        $href = parent::getHref();

        if($href) {
            if (strpos($this->_href, "___store") !== false) {
                preg_match_all('/(&*)?(___store=[a-z0-9_]*)+(&*)/i', $href, $matches);
                if($matches[2] != null) {
                    $replaceMatch = $matches[2];
                    if($matches[1] != null || $matches[3] != null) {
                        $replaceMatch = $matches[0];
                    }
                }
                $href = str_ireplace($replaceMatch, '', $href);
                $href = trim($href, '?');
            }
        }

        return $href;
    }
}

The __store parameter is used to switch between the store and load the appropriate content from the store view. I don't see a real need for that here as Magento also provides store view switcher that does the same thing.

0

Ok found the link code was generated from

/app/code/core/Mage/Catalog/Block/Widget/Link.php

I changed line 100 to

$this->_href = $this->_href;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.