2013-09-05 3 views
2

Jon Lin 덕분에 누군가 내 사이트 URL을 클릭하면 HOME 페이지 대신 PRODUCT 페이지로 이동하도록 PRESTASHOP 사이트를 리디렉션 할 수있었습니다.Prestashop에서 HOME을 클릭하면 주 제품 페이지로 이동합니다

현재 내 사이트에는 단 1 개의 제품 만 있으므로 항상 제품 페이지로 이동하고 싶습니다.

그러나 누군가가 내 사이트에 있고 다른 페이지 (어쩌면 장바구니에 있음)에있을 때 ..., 그리고 그들이 HOME을 클릭하면 주요 제품 페이지로 되돌아 가도록하고 싶습니다. 실제 홈 페이지가 아닙니다.

도움 주셔서 감사합니다.

+0

.htaccess를 사용하여 제품 페이지로 리디렉션하십시오. – Maykonn

+0

이미 .htaccess에서 RedirectMatch를 사용하여 사이트 URL을 제품 페이지로 리디렉션합니다. 그러나 일단 내 사이트에 들어 오면 어떤 명령이나 홈을 내 제품 페이지로 이동하는 방법을 모르겠습니다. –

답변

0

구성에서 SEO 및 URL에서 기본 URI를 제품 페이지로 변경하십시오.

+0

제품 url을 기본 URL에 넣으면 사이트의 내용이 손상됩니다. 그것은 모든 서식을 잃습니다. 무슨 일인가 내 사이트 정보와 텍스트입니다. 그것은 화면의 왼쪽 아래에있는 텍스트 일뿐입니다. 왜 그렇게하는지 확신하지 못합니다. –

0

수정하기 쉽습니다. 귀하의 제품 제품 ID가 5이고 현재 SEO 친화적 인 URL을 무시할 수 있습니다. 컨트롤러/front/IndexController.php 파일을 열고 initContent 함수에 다음 코드를 추가하십시오.

이제 사이트의 일부 홈 페이지로 이동하면 해당 사용자가 제품 페이지로 리디렉션됩니다. SEO 친숙한 URL이 활성화 된 경우 prestashop은 자동으로 해당 제품에 대한 prestashop의 검색 주소창에 SEO url을 표시합니다.

모드 디바이스는 제품 ID에 id_product 5를 변경해주십시오 거짓

로 설정해야합니다.

희망이 도움이 될 것입니다.

0

절대적으로 카테고리로 이동해야하는 경우 리디렉션 방법이 좋지만 대체 방법이 있습니다. SEO 이유로 리디렉션을해서는 안된다고 생각합니다. 내가 할 일은 홈페이지에 homefeatured 모듈을 추가하고 페이지 매김을 추가하여 카테고리와 동일하게 만드는 것입니다. 우선, 테스트하기 전에 핵심 파일과 테마 파일의 백업 파일을 만들 것입니다.하지만 1.5.4 버전에서는이 파일이 저에게 효과적이었습니다.

다음과 같은 코드를 ./themes/yourtheme/modules/homefeatured/<HERE>-paginationHomeFeatured.tpl라는 이름의 파일을 추가하면됩니다 ..

{* 
* 2007-2012 PrestaShop 
* 
* NOTICE OF LICENSE 
* 
* This source file is subject to the Academic Free License (AFL 3.0) 
* that is bundled with this package in the file LICENSE.txt. 
* It is also available through the world-wide-web at this URL: 
* http://opensource.org/licenses/afl-3.0.php 
* If you did not receive a copy of the license and are unable to 
* obtain it through the world-wide-web, please send an email 
* to [email protected] so we can send you a copy immediately. 
* 
* DISCLAIMER 
* 
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 
* versions in the future. If you wish to customize PrestaShop for your 
* needs please refer to http://www.prestashop.com for more information. 
* 
* @author PrestaShop SA <[email protected]> 
* @copyright 2007-2012 PrestaShop SA 
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 
* International Registered Trademark & Property of PrestaShop SA 
*} 
{if isset($no_follow) AND $no_follow} 
{assign var='no_follow_text' value='rel="nofollow"'} 
{else} 
{assign var='no_follow_text' value=''} 
{/if} 
{if isset($p) AND $p} 
    {assign var='requestPage' value=$base_dir|cat:'index.php'} 
    {assign var='requestNb' value=$base_dir|cat:'index.php'} 
{* {assign var='requestNb' value=$smarty.section.pagination.limits} *} 

<!-- Pagination --> 
<div id="pagination" class="pagination"> 
{if $start!=$stop} 
    <ul class="pagination"> 
    {if $p != 1} 
    {assign var='p_previous' value=$p-1} 
    <li id="pagination_previous"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_previous)}">&laquo;&nbsp;{l s='Previous'}</a></li> 
    {else} 
    <li id="pagination_previous" class="disabled"><span>&laquo;&nbsp;{l s='Previous'}</span></li> 
    {/if} 
    {if $start==3} 
    <li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li> 
    <li><a {$no_follow_text} href="{$link->goPage($requestPage, 2)}">2</a></li> 
    {/if} 
    {if $start==2} 
    <li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li> 
    {/if} 
    {if $start>3} 
    <li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li> 
    <li class="truncate">...</li> 
    {/if} 
    {section name=pagination start=$start loop=$stop+1 step=1} 
    {if $p == $smarty.section.pagination.index} 
    <li class="current"><span>{$p|escape:'htmlall':'UTF-8'}</span></li> 
    {else} 
    <li><a {$no_follow_text} href="{$link->goPage($requestPage, $smarty.section.pagination.index)}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li> 
    {/if} 
    {/section} 
    {if $pages_nb>$stop+2} 
    <li class="truncate">...</li> 
    <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li> 
    {/if} 
    {if $pages_nb==$stop+1} 
    <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li> 
    {/if} 
    {if $pages_nb==$stop+2} 
    <li><a href="{$link->goPage($requestPage, $pages_nb-1)}">{$pages_nb-1|intval}</a></li> 
    <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li> 
    {/if} 
    {if $pages_nb > 1 AND $p != $pages_nb} 
    {assign var='p_next' value=$p+1} 
    <li id="pagination_next"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_next)}">{l s='Next'}&nbsp;&raquo;</a></li> 
    {else} 
    <li id="pagination_next" class="disabled"><span>{l s='Next'}&nbsp;&raquo;</span></li> 
    {/if} 
    </ul> 
{/if} 
{if $nb_products > $products_per_page} 
    <form action="{if !is_array($requestNb)}{$requestNb}{else}{$requestNb.requestUrl}{/if}" method="get" class="pagination"> 
    <p> 
    {if isset($search_query) AND $search_query}<input type="hidden" name="search_query" value="{$search_query|escape:'htmlall':'UTF-8'}" />{/if} 
    {if isset($tag) AND $tag AND !is_array($tag)}<input type="hidden" name="tag" value="{$tag|escape:'htmlall':'UTF-8'}" />{/if} 
    <input type="submit" class="button_mini" value="{l s='OK'}" /> 
    <label for="nb_item">{l s='items:'}</label> 
    <select name="n" id="nb_item"> 
    {assign var="lastnValue" value="0"} 
    {foreach from=$nArray item=nValue} 
     {if $lastnValue <= $nb_products} 
      <option value="{$nValue|escape:'htmlall':'UTF-8'}" {if $n == $nValue}selected="selected"{/if}>{$nValue|escape:'htmlall':'UTF-8'}</option> 
     {/if} 
     {assign var="lastnValue" value=$nValue} 
    {/foreach} 
    </select> 
    {if is_array($requestNb)} 
     {foreach from=$requestNb item=requestValue key=requestKey} 
      {if $requestKey != 'requestUrl'} 
      <input type="hidden" name="{$requestKey|escape:'htmlall':'UTF-8'}" value="{$requestValue|escape:'htmlall':'UTF-8'}" /> 
      {/if} 
     {/foreach} 
    {/if} 
    </p> 
    </form> 
{/if} 
</div> 
<!-- /Pagination --> 
{/if} 

다음, 변경 homefeatured.tpl은 ..

{* 
* 2007-2013 PrestaShop 
* 
* NOTICE OF LICENSE 
* 
* This source file is subject to the Academic Free License (AFL 3.0) 
* that is bundled with this package in the file LICENSE.txt. 
* It is also available through the world-wide-web at this URL: 
* http://opensource.org/licenses/afl-3.0.php 
* If you did not receive a copy of the license and are unable to 
* obtain it through the world-wide-web, please send an email 
* to [email protected] so we can send you a copy immediately. 
* 
* DISCLAIMER 
* 
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 
* versions in the future. If you wish to customize PrestaShop for your 
* needs please refer to http://www.prestashop.com for more information. 
* 
* @author PrestaShop SA <[email protected]> 
* @copyright 2007-2013 PrestaShop SA 
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 
* International Registered Trademark & Property of PrestaShop SA 
*} 

<!-- MODULE Home Featured Products --> 
<div id="featured-products_block_center" class="block products_block clearfix"> 
    <p class="title_block">{l s='Featured products' mod='homefeatured'}</p> 
    {if isset($products) AND $products} 
     <div class="block_content"> 
      {assign var='liHeight' value=250} 
      {assign var='nbItemsPerLine' value=4} 
      {assign var='nbLi' value=$products|@count} 
      {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines} 
      {math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight} 
      <ul style="height:{$ulHeight}px;"> 
      {foreach from=$products item=product name=homeFeaturedProducts} 
       {math equation="(total%perLine)" total=$smarty.foreach.homeFeaturedProducts.total perLine=$nbItemsPerLine assign=totModulo} 
       {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if} 
       <li class="ajax_block_product {if $smarty.foreach.homeFeaturedProducts.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1} {/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - $totModulo)}last_line{/if}"> 
        <a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" />{if isset($product.new) && $product.new == 1}<span class="new">{l s='New' mod='homefeatured'}</span>{/if}</a> 
        <p class="s_title_block"><a href="{$product.link}" title="{$product.name|truncate:50:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a></p> 
        <div class="product_desc"><a href="{$product.link}" title="{l s='More' mod='homefeatured'}">{$product.description_short|strip_tags|truncate:65:'...'}</a></div> 
        <div> 
         <a class="lnk_more" href="{$product.link}" title="{l s='View' mod='homefeatured'}">{l s='View' mod='homefeatured'}</a> 
         {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if} 

         {if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE} 
          {if ($product.quantity > 0 OR $product.allow_oosp)} 
          <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')}?qty=1&amp;id_product={$product.id_product}&amp;token={$static_token}&amp;add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a> 
          {else} 
          <span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span> 
          {/if} 
         {else} 
          <div style="height:23px;"></div> 
         {/if} 
        </div> 
       </li> 
      {/foreach} 
      </ul> 
     </div> 
    {else} 
     <p>{l s='No featured products' mod='homefeatured'}</p> 
    {/if} 

    {* To add pagination - add three line below *} 
    <div class="content_sortPagiBar homefeaturedPaged"> 
     {include file="./paginationHomeFeatured.tpl"} 
    </div> 

</div> 
<!-- /MODULE Home Featured Products --> 

마지막으로는, homefeatured 편집 할 수 있습니다. 귀하의 핵심 디렉토리에 PHP.

<?php 
/* 
* 2007-2013 PrestaShop 
* 
* NOTICE OF LICENSE 
* 
* This source file is subject to the Academic Free License (AFL 3.0) 
* that is bundled with this package in the file LICENSE.txt. 
* It is also available through the world-wide-web at this URL: 
* http://opensource.org/licenses/afl-3.0.php 
* If you did not receive a copy of the license and are unable to 
* obtain it through the world-wide-web, please send an email 
* to [email protected] so we can send you a copy immediately. 
* 
* DISCLAIMER 
* 
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 
* versions in the future. If you wish to customize PrestaShop for your 
* needs please refer to http://www.prestashop.com for more information. 
* 
* @author PrestaShop SA <[email protected]> 
* @copyright 2007-2013 PrestaShop SA 
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 
* International Registered Trademark & Property of PrestaShop SA 
*/ 

if (!defined('_PS_VERSION_')) 
    exit; 

class HomeFeatured extends Module 
{ 
    private $_html = ''; 
    private $_postErrors = array(); 

    function __construct() 
    { 
     $this->name = 'homefeatured'; 
     $this->tab = 'front_office_features'; 
     $this->version = '0.9'; 
     $this->author = 'PrestaShop'; 
     $this->need_instance = 0; 

     parent::__construct(); 

     $this->displayName = $this->l('Featured products on the homepage.'); 
     $this->description = $this->l('Displays featured products in the middle of your homepage.'); 
    } 

    function install() 
    { 
     if (!Configuration::updateValue('HOME_FEATURED_NBR', 8) || !parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('header')) 
      return false; 
     return true; 
    } 

    public function getContent() 
    { 
     $output = '<h2>'.$this->displayName.'</h2>'; 
     if (Tools::isSubmit('submitHomeFeatured')) 
     { 
      $nbr = (int)(Tools::getValue('nbr')); 
      if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr)) 
       $errors[] = $this->l('An invalid number of products has been specified.'); 
      else 
       Configuration::updateValue('HOME_FEATURED_NBR', (int)($nbr)); 
      if (isset($errors) AND sizeof($errors)) 
       $output .= $this->displayError(implode('<br />', $errors)); 
      else 
       $output .= $this->displayConfirmation($this->l('Your settings have been updated.')); 
     } 
     return $output.$this->displayForm(); 
    } 

    public function displayForm() 
    { 
     $output = ' 
     <form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post"> 
      <fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend> 
       <p>'.$this->l('To add products to your homepage, simply add them to the "home" category.').'</p><br /> 
       <label>'.$this->l('Define the number of products to be displayed.').'</label> 
       <div class="margin-form"> 
        <input type="text" size="5" name="nbr" value="'.Tools::safeOutput(Tools::getValue('nbr', (int)(Configuration::get('HOME_FEATURED_NBR')))).'" /> 
        <p class="clear">'.$this->l('Define the number of products that you would like to display on homepage (default: 8).').'</p> 

       </div> 
       <center><input type="submit" name="submitHomeFeatured" value="'.$this->l('Save').'" class="button" /></center> 
      </fieldset> 
     </form>'; 
     return $output; 
    } 

    public function hookDisplayHeader($params) 
    { 
     $this->hookHeader($params); 
    } 

    public function hookHeader($params) 
    { 
     $this->context->controller->addCSS(($this->_path).'homefeatured.css', 'all'); 
    } 

    public function hookDisplayHome($params) 
    { 
/*  $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); 
     $nb = (int)(Configuration::get('HOME_FEATURED_NBR')); 
     $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)); 

     $this->smarty->assign(array(
      'products' => $products, 
      'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 
      'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 
     )); 

     return $this->display(__FILE__, 'homefeatured.tpl'); 
*/ 



     $controller = new FrontController(); 
      $controller->productSort(); 
     $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); 
      $nbProducts = $category->getProducts(NULL, NULL, NULL, $controller->orderBy, $controller->orderWay, true); 
     $controller->pagination($nbProducts); 

     $this->smarty->assign('nb_products', $nbProducts); 

     $products = $category->getProducts((int)Context::getContext()->language->id, (int)($controller->p), 
       (int)($controller->n), $controller->orderBy, $controller->orderWay); 

     $this->smarty->assign(array(
       'products' => $products, 
       'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 
       'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 
       'id_category' => (int)($category->id), 
       'id_category_parent' => (int)($category->id_parent), 
       'return_category_name' => Tools::safeOutput($category->name), 
       'path' => Tools::getPath((int)($category->id), $category->name) 
       )); 

     return $this->display(__FILE__, 'homefeatured.tpl'); 












    } 
} 

홈페이지에서 리디렉션되는 것을 방지하려면 제 해결책이 될 수 있습니다. 희망이 도움이됩니다.

관련 문제