Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Bestseller Box vs Cache

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Bestseller Box vs Cache
    am: 13. Juli 2016, 11:35:15
    Ich habe Kategorien in einem 1.06er Shop die nur zur Anzeige sind, wie z.B. die:
    https://www.j-k-fischer-verlag.de/J-K-Fischer-Verlag-EBooks---51.html
    Und auch neue Funktionen einprogrammiert, wie Autorenseiten:
    https://www.j-k-fischer-verlag.de/Marion-Schimmelpfennig-__-1153.html

    Auf solchen Seiten, die logischerweise null Verkäufe haben, taucht normalerweise keine Bestseller Box auf. Manchmal leider doch. Ich kann nicht nachvollziehen wann das passiert, ich habe es selbst schon gesehen, und sehe auch im Logfile, dass es hin und wieder passiert. Die Box wirft dann Fehler, weil sie versucht Daten anzuzeigen die nicht da sind:

    Code: XML  [Auswählen]
    [Tue Jul 12 11:13:58 2016] [warn] [client xxx.xxx.xxx.xxx] mod_fcgid: stderr: PHP Warning:  Illegal string offset 'PRODUCTS_IMAGE' in /var/www/vhosts/j-k-fischer-verlag.de/httpdocs/templates_c/%%1E^1EE^1EED7A60%%box_best_sellers.html.php on line 30

    Nur warum?!? Wenn die Box leer ist, sollte eigentlich keine kommen weil:
    Code: PHP  [Auswählen]
        if (count($box_content) > 0) {
            $box_best_sellers = '';
            // set cache ID
            if (!$cache) {
                $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE . '/boxes/box_best_sellers.html');
            } else {
                $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE . '/boxes/box_best_sellers.html', $cache_id);
            }

            $smarty->assign('box_BESTSELLERS', $box_best_sellers);
        }
     

    hier mal die komplette Datei /templates/wolkenkraft-rainbow/source/boxes/best_sellers.php:
    Code: PHP  [Auswählen]
    <?php

    /* -----------------------------------------------------------------------------------------
       $Id: best_sellers.php 1292 2005-10-07 16:10:55Z mz $  

       XT-Commerce - community made shopping
       http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))

       Copyright (c) 2003 XT-Commerce
       -----------------------------------------------------------------------------------------
       based on:
       (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
       (c) 2002-2003 osCommerce(best_sellers.php,v 1.20 2003/02/10); www.oscommerce.com
       (c) 2003      nextcommerce (best_sellers.php,v 1.10 2003/08/17); www.nextcommerce.org

       Released under the GNU General Public License
       -----------------------------------------------------------------------------------------
       Third Party contributions:
       Enable_Disable_Categories 1.3                Autor: Mikel Williams | mikel@ladykatcostumes.com

       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/

    // reset var
    $box_smarty = new smarty;
    $box_content = '';
    //$rebuild = false; //DokuMan - 2010-02-28 - fix Smarty cache error on unlink
    $box_smarty->assign('language', $_SESSION['language']);
    // set cache ID
    if (!CacheCheck()) {
        $cache = false;
        $box_smarty->caching = 0;
    } else {
        $cache = true;
        $box_smarty->caching = 1;
        $box_smarty->cache_lifetime = CACHE_LIFETIME;
        $box_smarty->cache_modified_check = CACHE_CHECK;
        $cache_id = $_SESSION['language'] . $current_category_id;
    }

    if (!$box_smarty->is_cached(CURRENT_TEMPLATE . '/boxes/box_best_sellers.html', $cache_id) || !$cache) {
        $box_smarty->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/');
        //$rebuild = true; //DokuMan - 2010-02-28 - fix Smarty cache error on unlink

        // include needed functions
        require_once(DIR_FS_INC . 'xtc_row_number_format.inc.php');

        //fsk18 lock
        $fsk_lock = '';
        if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
            $fsk_lock = ' and p.products_fsk18!=1';
        }
        $group_check = ''; //DokuMan - 2010-02-28 - set undefined variable group_check
        if (GROUP_CHECK == 'true') {
            $group_check = " and p.group_permission_" . $_SESSION['customers_status']['customers_status_id'] . "=1 ";
        }

        //BOF - DokuMan - 2010-07-12 - fix Smarty cache error on unlink
        $file = DIR_FS_CATALOG . 'cache/bestseller/' . (int)$current_category_id . '.cache';
        if (is_file($file)) {
            $box_content = unserialize(implode('', file($file)));
        } else {
            //EOF - DokuMan - 2010-07-12 - fix Smarty cache error on unlink

            if (isset ($current_category_id) && ($current_category_id > 0)) {
                //BOF - Dokuman - 2009-05-28 - Performance optimization by using primary keys
                // see http://shopnix.wordpress.com/2009/04/18/xtcommerce-performance/
                // and http://shopnix.wordpress.com/2009/04/22/performance-optimierung/
                /*
                  $best_sellers_query = "select distinct
                                                          p.products_id,
                                                          p.products_price,
                                                          p.products_tax_class_id,
                                                          p.products_image,
                                                        p.products_vpe,
                                                        p.products_vpe_status,
                                                        p.products_vpe_value,
                                                          pd.products_name from ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c, ".TABLE_CATEGORIES." c
                                                          where p.products_status = '1'
                                                          and c.categories_status = '1'
                                                          and p.products_ordered > 0
                                                          and p.products_id = pd.products_id
                                                          and pd.language_id = '".(int) $_SESSION['languages_id']."'
                                                          and p.products_id = p2c.products_id
                                                          ".$group_check."
                                                          ".$fsk_lock."
                                                          and p2c.categories_id = c.categories_id and '".$current_category_id."'
                                                          in (c.categories_id, c.parent_id)
                                                          order by p.products_ordered desc limit ".MAX_DISPLAY_BESTSELLERS;
                */

                $best_sellers_query = "select distinct
                                                   p.products_id,
                                                   p.products_price,
                                                   p.products_tax_class_id,
                                                   p.products_image,
                                                   p.products_vpe,
                                                   p.products_vpe_status,
                                                   p.products_vpe_value,
                                                                       p.products_class_id,
                                                                       p.exhausted_reason,
                                                                       p.products_sticker,
                                                   pd.products_name
                                                   from "
    . TABLE_PRODUCTS . " p,
                                                   "
    . TABLE_PRODUCTS_DESCRIPTION . " pd,
                                                   "
    . TABLE_PRODUCTS_TO_CATEGORIES . " p2c,
                                                   "
    . TABLE_CATEGORIES . " c
                                                   where p.products_status = '1'
                                                   and c.categories_status = '1'
                                                   and p.products_ordered > 0
                                                   and p.products_id = pd.products_id
                                                   and pd.language_id = '"
    . (int)$_SESSION['languages_id'] . "'
                                                   and p.products_id = p2c.products_id
                                                   "
    . $group_check . "
                                                   "
    . $fsk_lock . "
                                                   and p2c.categories_id = c.categories_id
                                                   and (c.categories_id = '"
    . (int)$current_category_id . "' or c.parent_id = '" . (int)$current_category_id . "')
                                                   order by p.products_ordered desc
                                                   limit "
    . MAX_DISPLAY_BESTSELLERS;
                // EOF - Dokuman - 2009-05-28 - Performance optimization
            } else {
                $best_sellers_query = "select distinct
                                                   p.products_id,
                                                   p.products_image,
                                                   p.products_price,
                                                   p.products_vpe,
                                                   p.products_vpe_status,
                                                   p.products_vpe_value,
                                                   p.products_tax_class_id,
                                                                       p.products_class_id,
                                                                       p.exhausted_reason,
                                                                       p.products_sticker,
                                                   pd.products_name from "
    . TABLE_PRODUCTS . " p,
                                                   "
    . TABLE_PRODUCTS_DESCRIPTION . " pd
                                                   where p.products_status = '1'
                                                   "
    . $group_check . "
                                                   and p.products_ordered > 0
                                                   and p.products_id = pd.products_id "
    . $fsk_lock . "
                                                   and pd.language_id = '"
    . (int)$_SESSION['languages_id'] . "'
                                                   order by p.products_ordered desc
                                                   limit "
    . MAX_DISPLAY_BESTSELLERS;
            }
            $best_sellers_query = xtDBquery($best_sellers_query);
            if (xtc_db_num_rows($best_sellers_query, true) >= MIN_DISPLAY_BESTSELLERS) {

                $rows = 0;
                $box_content = array();
                while ($best_sellers = xtc_db_fetch_array($best_sellers_query, true)) {
                    $rows++;
                    $image = '';

                    $best_sellers = array_merge($best_sellers, array('ID' => xtc_row_number_format($rows)));
                    $box_content[] = $product->buildDataArray($best_sellers);

                }

                /**
                 * Add the review ratings to all products
                 */

                foreach($box_content as &$content):
                    $ratingStats = getRatingStats($content['PRODUCTS_ID']);

                    $content['PRODUCTS_AVERAGE_RATING'] = $ratingStats['average_rating'];
                    $content['PRODUCTS_RATING_AMOUNT'] = $ratingStats['rating_amount'];
                    $content['PRODUCTS_AVERAGE_RATING_PERCENT']= $ratingStats['average_rating_percent'];
                endforeach;
            }




            $box_smarty->assign('box_content', $box_content);
        }
        //BOF - DokuMan - 2010-07-12 - fix Smarty cache error on unlink
        // set cache ID
        /*
         if (!$cache || $rebuild) {
          if (count($box_content)>0) {
            if ($rebuild)  $box_smarty->clear_cache(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html', $cache_id);
            $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html',$cache_id);
            $smarty->assign('box_BESTSELLERS', $box_best_sellers);
          }
        } else {
          $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html', $cache_id);
          $smarty->assign('box_BESTSELLERS', $box_best_sellers);
        }
        */

        if (count($box_content) > 0) {
            $box_best_sellers = '';
            // set cache ID
            if (!$cache) {
                $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE . '/boxes/box_best_sellers.html');
            } else {
                $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE . '/boxes/box_best_sellers.html', $cache_id);
            }

            $smarty->assign('box_BESTSELLERS', $box_best_sellers);
        }
    }
    //EOF - DokuMan - 2010-07-12 - fix Smarty cache error on unlink
    ?>


    Linkback: https://www.modified-shop.org/forum/index.php?topic=35341.0

    webald

    • modified Team
    • Beiträge: 2.791
    Re: Bestseller Box vs Cache
    Antwort #1 am: 13. Juli 2016, 13:35:19
    1. Warum ist in den SQL-Abfragen kein Join drin? War das Standard?

    2. Ist in bestseller.html sowas wie {if $box_data.PRODUCTS_IMAGE} drin?

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Re: Bestseller Box vs Cache
    Antwort #2 am: 13. Juli 2016, 13:50:31
    1. Habe eben die original Templatedatei verglichen, ja auch da ist die short Syntax für JOIN verwendet worden.
    Code: PHP  [Auswählen]
    $best_sellers_query = "select distinct
                                                          p.products_id,
                                                          p.products_price,
                                                          p.products_tax_class_id,
                                                          p.products_image,
                                                        p.products_vpe,
                                                        p.products_vpe_status,
                                                        p.products_vpe_value,
                                                          pd.products_name from "
    .TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c, ".TABLE_CATEGORIES." c
                                                          where p.products_status = '1'
                                                          and c.categories_status = '1'
                                                          and p.products_ordered > 0
                                                          and p.products_id = pd.products_id
                                                          and pd.language_id = '"
    .(int) $_SESSION['languages_id']."'
                                                          and p.products_id = p2c.products_id
                                                          "
    .$group_check."
                                                          "
    .$fsk_lock."
                                                          and p2c.categories_id = c.categories_id and '"
    .$current_category_id."'
                                                          in (c.categories_id, c.parent_id)
                                                          order by p.products_ordered desc limit "
    .MAX_DISPLAY_BESTSELLERS;
    2. Ja
    Code: XML  [Auswählen]
    {* ========================================================================================
    (( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! )) Rainbow Theme for modified eCommerce Shopsoftware [www.modified-shop.org]
    Autor: Michael Fürst
    URL: http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))
    Follow me: @wolkenkraft

    (c) 2001 - 2014 Michael Fürst / (( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! )) Software Engineering (www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! )))
    Please pay attention to our license information: http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))/dokumentationen/lizenzen/
    ===========================================================================================
    File information:
    box_best_sellers.html shows the most sold items in the shop
    ===========================================================================================
    *}

    {loadconfig}
    {config_load file="../templates/wolkenkraft-rainbow/lang/$language.conf" section="global"}
    {config_load file="$language/lang_$language.conf" section="boxes"}

    <!-- widget: Bestseller -->
    <div class="widget widget-bestseller">

        <h3 class="widget-title">{#heading_best_sellers#}</h3>

        <!-- .widget-content -->
        <div class="widget-content">

            <!-- .product-list -->
            <ul class="product-list">
                {foreach name=aussen item=box_data from=$box_content}
                <li class="text-center mbl">
                    {if $box_data.PRODUCTS_IMAGE}
                        <a href="{$box_data.PRODUCTS_LINK}" class="image">
                                                    {sticker products_exhausted_reason=$box_data.PRODUCTS_EXHAUSTED_REASON products_sticker=$box_data.PRODUCTS_STICKER}
                            <img src="{$box_data.PRODUCTS_IMAGE}" class="img-rounded" alt="{$box_data.PRODUCTS_NAME}" title="{$box_data.PRODUCTS_NAME}" />
                            {if $box_data.PRODUCTS_PRICE|isspecialprice}<span class="sticker-container top-right"><span class="sticker sale"><span class="fui-fire"></span></span></span>{/if}
                                                    {sticker products_class_id=$box_data.PRODUCTS_CLASS_ID}
                        </a>
                    {/if}
                    <h2><a href="{$box_data.PRODUCTS_LINK}">{$box_data.PRODUCTS_NAME}</a></h2>
                    <div class="normal-price mbm">
                        <h5>{$box_data.PRODUCTS_PRICE}</h5>
                        <p>
                            {if $box_data.PRODUCTS_VPE}{$box_data.PRODUCTS_VPE}<br />{/if}
                            {$box_data.PRODUCTS_TAX_INFO}<br />
                            {$box_data.PRODUCTS_SHIPPING_LINK|regex_replace:'/<a[^>]*href="([^"]*)"[^>]*>(.*)<\/a>/':'<a href="$1" data-type="iframe" class="venobox-modal">$2</a>'}
                        </p>

                    </div>

                    <!-- .rating -->
                    {if $reviewsRead}
                        {if $box_data.PRODUCTS_RATING_AMOUNT > 0 || $templateConfig.ratingShowEmptyRating=='true'}
                        <div class="rating">
                            <div class="rating-wrap">
                                <div class="rating-stars" style="width: {$box_data.PRODUCTS_AVERAGE_RATING_PERCENT}%"> </div>
                            </div>
                            <p class="info">
                                {if $box_data.PRODUCTS_RATING_AMOUNT > 1}
                                    {$box_data.PRODUCTS_RATING_AMOUNT} {#reviews#}
                                {elseif $box_data.PRODUCTS_RATING_AMOUNT==0}
                                    {#no_review#}
                                {else}
                                    {$box_data.PRODUCTS_RATING_AMOUNT} {#review#}
                                {/if}
                            </p>
                        </div>
                        {/if}
                    {/if}
                    <!-- /.rating -->

                </li>
                {/foreach}

            </ul>
            <!-- /.product-list -->

        </div>
        <!-- /.widget-content -->

    </div>
    <!-- /widget: Bestseller -->

    webald

    • modified Team
    • Beiträge: 2.791
    Re: Bestseller Box vs Cache
    Antwort #3 am: 13. Juli 2016, 14:07:16
    Erst dachte ich  :nixweiss:

    Aber ich weiss es:

    $box_content = '';
    echo count($box_content); <= 1 !!!

    $box_content = array();
    echo count($box_content);  <= 0

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Re: Bestseller Box vs Cache
    Antwort #4 am: 13. Juli 2016, 14:15:24
    :datz: Manchmal sieht man den Wald vor lauter Bäumen nicht! Vielen Dank für die Hilfe!
    2 Antworten
    2796 Aufrufe
    24. Juni 2013, 02:09:03 von Aquaboy
    5 Antworten
    3745 Aufrufe
    09. März 2012, 22:14:06 von rockmartin
    6 Antworten
    6722 Aufrufe
    07. Februar 2010, 19:59:35 von Tomcraft
               
    anything