Joomla 3.2/k2 2.6.5
I use this code to make seo url for k2 items link.
$item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias), $item->catid.':'.urlencode($item->categoryalias))));
and It gives me an Url path like this:
MYSITE.COM/CAT/SUBCAT/SUB2cat/ITEM.HTML
Is there any way to convert it to one of these addresses?
MYSITE.COM/ITEM.HTML
MYSITE.COM/CAT/ITEM.HTML
MYSITE.COM/SUB2CAT/ITEM.HTML
Related
I am looking help about smarty global variables. How to get friendly URL variable for using it in smarty template of the Prestashop.
I have found this {$smarty.server.REQUEST_URI} , but I got only full URL.
It looks like:
/en/our-products/73-lighted-mirror-tokyo-70-x-32.html
I need to get only 73-lighted-mirror-tokyo-70-x-32 sting.
Help, please.
You can also use the getUrlRewriteInformations() function from the Product class in PrestaShop.
It can return the information about the URL Rewrites of any product using the following line of code:
$rewrite_info = Product::getUrlRewriteInformations($id_product);
Great, it was help full. I have found the solution for get current product slug on the product page of the Prestashop:
Source URL: /en/our-products/2-backlit-mirror-rectangle-20-x-28.html
{assign var="var" value=$smarty.server.REQUEST_URI}
{assign var="output" value=$var|substr:0:($var|strpos:"."+0)}
{assign var=slug value=$output|substr:($output|strpos:"/"+17)}
{$slug}
Slug: 2-backlit-mirror-rectangle-20-x-28
I am trying to setup an A/B test using the VWO interface for a Magento site.
I would like to target all product pages, but I do not see a clear way to match every single URL.
FYI, the products are using rewrite rules, eg:
website.com/product-1
website.com/some-other-product-name
I cannot use a regex as this would pick up other pages, eg:
website.com/about-us
You need to add the following code to the pages you want to target.
var _vis_opt_url = 'http://website.com/my_pages_i_want_to_target';
The in VWO interface you can target that url.
https://vwo.com/knowledge/using-custom-urls/
I'm currently setting up a Magento shop that will support a few different languages.
One issue that I ran into is that I can't find out how to link two CMS pages together, so that when a user switches their language, they are automatically forwarded to the current CMS page but in their preferred language. One option would be to use the same URL key for both pages, but that wouldn't be very user friendly as some users would then see URL keys not in their native language.
Let me give you an example:
I have an "About us" page. In the English version of the store, the URL of that page is /about-us. Now a German user lands on that page and switches his language. But because the German equivalent to "About us" is "Über uns", the German version of that page is at /ueber-uns, so the user would be presented a 404 page because no German version of /about-us exists.
Does anybody know how to solve this issue?
Update: Did some more research and found nothing. I can't believe I am the only one with this problem? The go-to solution, using the same URL key for all languages, seems very ugly and not very user friendly!
So, the only solution that I found was to manually create a redirect for each page in the Magento Rewrite Rules. Do do that, go to Catalog -> URL Rewrite Management and add each page in the following format:
So if a user is using the Francais store view and requests /url-in-english, the redirect will kick in and redirect the user to /url-in-french.
This is of course not an ideal solution, it would be preferred if two pages could be "linked" directly, but I suppose I will have to use this for the moment. If anybody comes up with a better solution feel free to add yours!
I have seen this bug in Magento CE 1.8.0.0. The problem here was a wrong assignment in \app\code\core\Mage\Core\Model\Url\Rewrite\Request.php.
To solve this problem it is sufficient to change the assignment of $fromStore in the protected function _rewriteDb() within the Mage_Core_Model_Url_Rewrite_Request class from
$fromStore = $this->_request->getQuery('___from_store');
to
$fromStore = Mage::getModel('core/store')->load($this->_request->getQuery('___from_store'), 'code')->getId();
with the result that we can access the $stores array with the right key (with the store id instead of the store code). With this the if statement
if (!empty($stores[$fromStore])) {
works in the right way.
As a reminder: Do not modify core files. Just copy \app\code\core\Mage\Core\Model\Url\Rewrite\Request.php to \app\code\local\Mage\Core\Model\Url\Rewrite\Request.php before any change.
You will find this answer in German here: Rewrite von Seiten in verschiedenen Sprachen und verschiedenen URL Keys in Magento
Above solution works but takes a while. We just did the following to rewrite the language changer url when on a cms page to go to the base url:
Add the following code to app/design/frontend/default/template_name/template/page/switch/languages.html after the part where the $url variable is filled (on our it was like
$url = /*explode( '?',*/$_lang->getCurrentUrl()/*);*/;
so we added the following:
if(($this->getRequest()->getModuleName() == 'cms') && strpos($url,'.com/')){$url = strstr($url, '.com/', true) . '.com/';}
elseif(($this->getRequest()->getModuleName() == 'cms') && strpos($url,'.de/')){$url = strstr($url, '.de/', true) . '.de/';}
elseif(($this->getRequest()->getModuleName() == 'cms') && strpos($url,'.nl/')){$url = strstr($url, '.nl/', true) . '.nl/';}
What I did here is check if on a cms page and check if the url contains either .com/ ; .de/ or .nl and strip the part before then add the domain extension back.
in our example: http://www.mega-watch.com/about-us?blabla will become http://www.mega-watch.com/
Hope this helps someone out..
How would one load a product model in Magento, if the product id is not available and only the product's url is? For example, I want to retrieve the product model from it's friendly url, such as
electronics/cameras/olympus-stylus-750-7-1mp-digital-camera.html
I found the following code in another post:
$oRewrite = Mage::getModel('core/url_rewrite')->loadByRequestPath(
$path
);
but it doesn't seem to work correctly. The Magento documentation is very lacking in this area; does anyone know how to accomplish this?
Here's an alternative solution.
First use the URL rewrite model to find the route which matches your product:
$vPath = 'electronics/cameras/olympus-stylus-750-7-1mp-digital-camera.html';
$oRewrite = Mage::getModel('core/url_rewrite')
->setStoreId(Mage::app()->getStore()->getId())
->loadByRequestPath($vPath);
Then you can call getProductId() on the route to locate the produc's id:
$iProductId = $oRewrite->getProductId();
Finally if you require the product model object itself it's then a simple matter to call:
$oProduct = Mage::getModel('catalog/product')->load($iProductId);
The main difference between the above, and the code example you've posted is the call to setStoreId. The same product may have different URLs depending on which store it's in, so the routing component needs to have the appropriate store context before it can locate the product to display.
The advantages of this over Zachary Schuessler's solution is that using the URL rewriter will locate the correct product every time if the trailing portions of the url are the same for different products (e.g. folder1/my-product-name and folder2/my-product-name are different products). Using the URL rewriter also works in situations where "folder1/my-product" refers to different products on different stores. This may or may not apply to your environment.
I'm curious as to why you need to do this, since this might not be the best solution. This should be easy enough using the addAttributeToFilter() method on the collection:
$path = 'folder/folder/my-product-name';
// Get the product permalink
$productName = explode('/', $path);
$productName = end($productName);
// Filter the url_path with product permalink
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('url_path', $productName)
->getFirstItem();
Zend_Debug::dump($products->getData());exit;
I have a static block in Magento with this content:
<li>Contact Us</li>
I would like to replace the # with the site's base url. I want it to retrieve this dynamically.
Try adding this to your static block:
Link to Base URL
That should create a link to your store's base URL.
you can use this {{store direct_url="contacts"}}
For example:
contact us
For those that are still looking for a solution, the following should do the trick for you...
For the unsecured base URL:
{{config path='web/unsecure/base_url'}}
Or for the secured base URL:
{{config path='web/secure/base_url'}}
Try this
Contact Us
You can add store URL in static block:
Your link
A bit more clear and practical scenario (for all level of users) would be:
Suppose, we have added a static-block in footer-area/elsewhere. In that static-block we have words like this: Contact Us
And we want to add a cms-page link of that words(Contact Us).
Nice and simple way with elaborated steps:
Step-1: Create a page through CMS>Pages. In 'Page Information' Tab section we set URL Key* page-contact-us
Necessary Text can be written through the content tab area.
Step-2: After opening up our Static-block through CMS>Static Blocks, we have to write the code like this way:
Contact Us
That's all, the Base URL of that Static-block is now activated and can be retrieved dynamically.