Kerm Posted June 1, 2015 Share Posted June 1, 2015 This: $url = $this->context->link->getProductLink($product); Or this: $product = new Product((int)$id_product); $link = new Link(); $url = $url = $link->getProductLink($product); Show product link with out category name in url.... I need some link like that:site.com/category-name/22[spam-filter]product-link.html 1 Link to comment Share on other sites More sharing options...
PascalVG Posted June 2, 2015 Share Posted June 2, 2015 In product.php, I see that they first fill the 'category' array as well, and add it to the getProductLink function: $row['category'] = Category::getLinkRewrite((int)$row['id_category_default'], (int)$id_lang); $row['link'] = $context->link->getProductLink((int)$row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']); Maybe this helps? pascal. 3 Link to comment Share on other sites More sharing options...
Scully Posted November 11, 2015 Share Posted November 11, 2015 Pascal, this helped me too. It only works if you fill in the category first. Link to comment Share on other sites More sharing options...
theillo Posted May 15, 2019 Share Posted May 15, 2019 (edited) Not sure if this answers your question: How to get the Product link: Context::getContext()->link->getProductLink( $id_product ); How to get the Category link: Context::getContext()->link->getCategoryLink( $id_category ); Oh, actually I think now I understand what you're asking: you want to change the URL structure, so you've gotta go to Admin Office -> Preferences -> Seo & URLs -> scroll down to SCHEMA OF URLS I have mine set to {category:/}{id}/{rewrite} so I get exactly what you want I believe Edited May 15, 2019 by theillo (see edit history) Link to comment Share on other sites More sharing options...
Tom Posted November 27, 2019 Share Posted November 27, 2019 Hello, dont you know why is this code dont working? It wont generate product link 😮 If product have combination, you can disable "Add to Cart" button on Category page. So i want to have this button linked to the product page. Presta 1.7 <a href="{$product.url}">Choose combination</a> Thank you for help. Link to comment Share on other sites More sharing options...
Tom Posted November 27, 2019 Share Posted November 27, 2019 The full code of my productattributes.tpl <div class="an_productattributes"> <form method="post" class="an_productattributesForm" action="{$cart|escape:'htmlall':'UTF-8'}"> <input name="token" value="{$token|escape:'htmlall':'UTF-8'}" type="hidden"> <input name="id_product" value="{$productId|escape:'htmlall':'UTF-8'}" type="hidden"> {*<input name="id_customization" value="0" placeholder="" type="hidden"> *} {if $config.display_quantity!='1'} <input name="qty" type="hidden" value="{$minimal_quantity|escape:'htmlall':'UTF-8'}" min="{$minimal_quantity|escape:'htmlall':'UTF-8'}"> {/if} {if $config.type_view=='standart'} <div class="js-an_productattributes-standart"> {include file='./product-variants.tpl'} </div> {/if} {if $config.type_view=='select' AND isset($productData) AND count($productData)>0} <div class="an_productattributes-select js-an_productattributes-select"> {include file='./product-select.tpl'} </div> {/if} {if $config.display_add_to_cart=='1'} <div class="an_productattributes-qty-add clearfix"> {if $config.display_quantity=='1'} <div class="an_productattributes-qty-container"> <input type="number" name="qty" value="{$minimal_quantity|escape:'htmlall':'UTF-8'}" class="input-group form-control an_productattributes-qty" min="{$minimal_quantity|escape:'htmlall':'UTF-8'}" aria-label="Quantity" style="display: block;"> </div> {/if} {if $availableForOrder !='0'} <div class="an_productattributes-add"> <button class="btn an_productattributes-add-to-cart-btn js-an_productattributes-add-to-cart" data-button-action="add-to-cart" type="submit" > <i class="material-icons shopping-cart"></i> {l s='Add to cart' mod='an_productattributes'} </button> </div> {/if} {if $availableForOrder !='1'} <div class="an_productattributes-add"> <a href="{$product.url}"> <button class="btn an_productattributes-add-to-cart-btn"> <i class="material-icons calendar_today"></i> Vyberte termín (Choose combination) </button> </a> </div> {/if} </div> {/if} </form> </div> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now