Ankündigung

Einklappen
Keine Ankündigung bisher.

Joomla Virtuemart - Short Description in latest products

Einklappen

Neue Werbung 2019

Einklappen
Dieses Thema ist geschlossen.
X
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Joomla Virtuemart - Short Description in latest products

    Hallo,

    ich habe mich hier im Forum angemeldet weil ich kurz vor der Verzweiflung stehe. Ich bin nicht sehr erfahren was PHP angeht deshalb bitte ich um Entschuldigung wenn ich eine Noobie frage stellen sollte.

    Also, ich arbeite mit Joomla und Virtuemart um einen Online Shop zu realisieren. Ich biete MP3s an und habe den 1pixeloutplayer erfolgreich in die Virtuemart short description einfügen können um eine Preview für jede MP3 anbieten zu können. Nun möchte ich gerne die short description innerhalb eines Moduls (latest products) einfügen. Ich bin im Internet auf folgende Anleitung gestoßen.
    http://forum.virtuemart.net/index.php?topic=64564.30

    Ich habe alle Schritte genau so ausgeführt wie es dort angegeben ist. Nur mit der ps_product.php habe ich Probleme. Ich habe den Code für diese Datei 1zu1 aus dieser Anleitung kopiert aber erhalte folgenden Fehlercode:
    Fatal error: Class 'vm_ps_product' not found in administrator/components/com_virtuemart/classes/ps_product.php on line 4

    Der Code für die ps_product.php lautet wie folgt:

    Code:
    <?php
    if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
    
    class ps_product extends vm_ps_product {
    
      /**
      * Alternative product_snapshot method which reads the product's description and
      * puts it into the template
      */
      /**
       * Returns HTML code for a snapshot of a product based on the product sku.
       * This was written to provide a quick way to display a product inside of modules
       *
       * @param string $product_sku The SKU identifying the product
       * @param boolean $show_price Show the product price?
       * @param boolean $show_addtocart Show the add-to-cart link?
       * @param boolean $show_product_name Show the product name?
       */
      function product_snapshot( $product_sku, $show_price=true, $show_addtocart=true, $show_product_name = true ) {
    
        global $sess, $mm_action_url;
    
        $db = new ps_DB;
    
        require_once(CLASSPATH.'ps_product_category.php');
        $ps_product_category = new ps_product_category;
    
        $q = "SELECT product_id, product_name, product_parent_id, product_thumb_image, product_desc FROM #__{vm}_product WHERE product_sku='$product_sku'";
        $db->query( $q );
    
        if ($db->next_record()) {
          $product_id = $db->f("product_id" );
          $tpl = new $GLOBALS['VM_THEMECLASS']();
         
          $cid = $ps_product_category->get_cid( $product_id );
    
          $tpl->set( 'product_id', $product_id);
          $tpl->set( 'product_name', $db->f("product_name") );
          $tpl->set( 'product_desc', $db->f("product_desc") );
          $tpl->set( 'show_product_name', $show_product_name );
         
          if ($db->f("product_parent_id")) {
            $url = "?page=shop.product_details&category_id=$cid&flypage=".$this->get_flypage($db->f("product_parent_id"));
            $url .= "&product_id=" . $db->f("product_parent_id");
          } else {
            $url = "?page=shop.product_details&category_id=$cid&flypage=".$this->get_flypage($db->f("product_id"));
            $url .= "&product_id=" . $db->f("product_id");
          }
          $product_link = $sess->url($mm_action_url. "index.php" . $url);
          $tpl->set( 'product_link', $product_link );
          $tpl->set( 'product_thumb_image', $db->f("product_thumb_image"), "alt=\"".$db->f("product_name")."\"");
    
          if (_SHOW_PRICES == '1' && $show_price) {
            // Show price, but without "including X% tax"
            $price = $this->show_price( $db->f("product_id"), true );
            $tpl->set( 'price', $price );
          }
          if (USE_AS_CATALOGUE != 1 && $show_addtocart
              && isset( $GLOBALS['product_info'][$product_id]['price']['product_price_id'] ) // Product must have a price to add it to cart
              && !$this->product_has_attributes($product_id, true)
     // Parent Products and Products with attributes can't be added to cart this way
              ) {
            $url = "?page=shop.cart&func=cartAdd&product_id=" .  $db->f("product_id");
            $addtocart_link = $sess->url($mm_action_url. "index.php" . $url);
            $tpl->set( 'addtocart_link', $addtocart_link );
          }
          return $tpl->fetch( 'common/productsnapshot.tpl.php');
        }
       
        return ´´;
       
      }
    
    }
    ?>
    Ich habe schon in dem anderen Forum geposted aber niemand konnte mir weiterhelfen, deswegen habe ich gehofft vielleicht hier jemanden zu finden der mir helfen könnte. Würde mich über jeden Hilfsversuch sehr freuen.

  • #2
    Die Klasse "vm_ps_product" kennt er nicht. Wenn Virtuemart nen Autoloader hat, binde den ein. Oder du bindest die Klasse selbst ein per require_once.

    P.S.: Willkommen im Forum (Bitte anstelle von [code] [php]-tags verwenden.)
    I like cooking my family and my pets.
    Use commas. Don't be a psycho.
    [URL="http://jscouch.de"]Blog[/URL] - [URL="http://coverflowjs.github.io/coverflow/"]CoverflowJS[/URL]

    Kommentar


    • #3
      Hey Rudygotya,

      Vielen Dank für deine Antwort. Mittlerweile habe ich herausgefunden, dass ich vergessen habe einen Ordner in einem anderen Pfad anzulegen und dort die modifizierte ps_product.php abzulegen. Die originale ps_product.php sollte bleiben wo sie war. Nur bekomme ich nun die neue Fehlermeldung
      Fatal error: Cannot redeclare class vm_ps_product in /components/com_virtuemart/themes/default/user_class/ps_product.php on line 74

      Zumindest hat sich die Fehlermeldung schonmal geändert

      Kommentar


      • #4
        Hat jemand hier vielleicht noch eine Idee woran es liegen könnte?

        Kommentar


        • #5
          Zitat von treble Beitrag anzeigen
          Die originale ps_product.php sollte bleiben wo sie war.
          Das geht nicht. Die Quittung folgt dann auf dem Fuße:
          Nur bekomme ich nun die neue Fehlermeldung
          Fatal error: Cannot redeclare class vm_ps_product in /components/com_virtuemart/themes/default/user_class/ps_product.php on line 74

          Kommentar


          • #6
            Hey,

            vielen Dank für deine Antwort.

            Doch das war schon richtig so.

            Das Problem war die Zeile return ´´; Es sollten normale Anführungszeichen sein. Habs jetzt zum laufen bekommen.

            Vielen dank aber..

            LG

            Kommentar


            • #7
              [MOD: closed wegen x-porting (siehe http://phpforum.de/forum/showthread.php?t=268554)]
              Viele Grüße,
              Dr.E.

              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              1. Think about software design [B]before[/B] you start to write code!
              2. Discuss and review it together with [B]experts[/B]!
              3. Choose [B]good[/B] tools (-> [URL="http://adventure-php-framework.org/Seite/088-Why-APF"]Adventure PHP Framework (APF)[/URL][URL="http://adventure-php-framework.org"][/URL])!
              4. Write [I][B]clean and reusable[/B][/I] software only!
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

              Kommentar

              Lädt...
              X