2013-04-09 3 views
0

제품 목록에서 "온라인으로 만"표시된 항목을 제외하고 싶습니다.prestashop 제품 목록에서 제품을 제외하십시오.

제품-list.tpl의 시작은 다음과 같습니다

<li {if $product.online_only}style="display:none"{/if}> 

목록에서 제품을 제거하지만 그들은 여전히 ​​목록에 공간을 차지 :

<ul id="product_list" class="categorie_product clear"> 
    {foreach from=$products item=product name=products} 
     <li class="ajax_block_product ........etc........> 

이 가하고 있습니다. 그래서 나는 유일한 방법은 foreach 자체에서 온라인으로 설정되어있는 제품을 제외하는 것이라고 생각하고 있지만이 작업을 수행하는 방법에 대해서는 다소 분실했습니다.

답변

0

편집 : 아, 예 페이지 매김을 잊어 버렸습니다. MySQL 쿼리에서 해당 제품을 제외해야하는 것처럼 보입니다.

클래스/category.php로 이동하여 getProducts 함수를 찾습니다.

if ($getTotal)을 찾아 이것으로 마지막 줄을 바꿉니다 '.($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '').' AND p.online_only = 0'); 이 NOT (온라인 전용) 제품의 수를 반환합니다, 그래서 매김이 제대로 작동합니다.

바로 아래에 변수 $ sql이 표시됩니다. 마지막 줄을 다음으로 바꿉니다. '.($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '').' AND p.online_only = 0'; NOT 제품 만 온라인으로 가져올 수 있습니다.

제대로 작동합니다. 이제 데이터베이스에서 가져 오지 못하는 제품 (온라인 전용) 만 가져 오기 때문에 {앞에서 언급 한 {계속}이 필요하지 않습니다.

저에게 맞는 작품인지 알려주세요.

+0

그 부분에 대한 트릭을 만들었지 만 비 온라인 제품은 더 이상 페이지 코드에 나타나지 않지만 문제는 여전히 존재합니다. – user2263007

+0

그래서 문제는 실제로 범주에서 모든 제품을 가져 오는 페이지 매김에 해당하므로 제품 목록에 더 많은 제품이 있다고 생각합니다. 예를 들어 실제 16 개 중 5 개가 현재 표시되지만 페이지는 다음 "페이지"의 제품으로 채워지지 않으므로 페이지 당 원하는 16을 표시합니다. – user2263007

+0

답변 됨. –

0

네, 그게 제가 한 일이지만 효과는 없습니다. 전체적으로 category.php의 부분 :

 if ($getTotal) 
    { 
     $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' 
     SELECT COUNT(cp.`id_product`) AS total 
     FROM `'._DB_PREFIX_.'product` p 
     LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product` 
     WHERE cp.`id_category` = '.(int)($this->id).($active ? ' AND p.`active` = 1' : '').' 
     '.($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '').' AND p.online_only = 0'); 
     return isset($result) ? $result['total'] : 0; 
    } 

    $sql = ' 
    SELECT p.*, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, cl.`name` AS category_default, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new, 
     (p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1)) AS orderprice 
    FROM `'._DB_PREFIX_.'category_product` cp 
    LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` 
    LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) 
    LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)($id_lang).') 
    LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).') 
    LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) 
    LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).') 
    LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` 
               AND tr.`id_country` = '.(int)Country::getDefaultCountryId().' 
               AND tr.`id_state` = 0) 
    LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`) 
    LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)($id_lang).') 
    LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` 
    WHERE cp.`id_category` = '.(int)($this->id).($active ? ' AND p.`active` = 1' : '').' 
    '.($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '').' AND p.online_only = 0'; 
+0

맞아요. 다른 설치에서 작동하는지 테스트 한 결과, WHERE p.online_only = 0 $ sql 부분의 두 번째 줄부터 두 번째 줄까지를 테스트했습니다. Anycase 내 시스템의 일부 파일에서 뭔가를 엉망으로 만들었을 것입니다. (작업 중) 입력을 주셔서 감사합니다. – user2263007

+0

멋지다! "where p.online_only = 0"을 $ result와 $ sql 모두에 추가하면 위에서 제안한 것과 정확히 일치합니다. 내 대답이 도움이된다고 생각되면 선택해보십시오 :) –

관련 문제