Il sito dedicato all'informatica ideato da Iasparra Francesco

ZenCart: inviare i dati a TrovaPrezzi

  • Come inviare i dati a TrovaPrezzi con il modulo Ceon URI Mapping (SEO) attivo su ZenCart

  • Data: 15/01/2005 Autore: Iasparra Francesco 

Zencart

Dal modulo di TrovaPrezzi modificare il file trovaprezzi_zencart.php nelle righe sotto riportate:

$stringToPrint = $coreFunctions->GetListingRow($zencartProvider, $row, $availability, $descrizione1, $originalPrice, $final_price, $base_url, $reftracking, $cat_list, $site_images_url, $shippingCost);

Alla funzione GetListingRow viene aggiunta la variabile $zencartProvider.

Ora nel file EcommerceCore/ZenCartCoreFunctions.php, riscriviamo la funzione sopra citata nel seguente modo:

<?php
require_once "CoreFunctions.php";
require_once "StringFunctions.php";
require_once 'DbProviderBase.php';

class ZenCartCoreFunctions extends CoreFunctions
{

    protected $queryListingStringFormat =
        "SELECT p.products_id,p.products_status,p.products_image,p.manufacturers_id,p.products_price,p.products_weight,
p.products_tax_class_id,p.products_quantity,pd.products_name,pd.products_description,p2c.categories_id,c.parent_id,
c.categories_id,cd.categories_name,IF(p.manufacturers_id = 0, NULL, m.manufacturers_name) AS brand,IF(s.status,
 s.specials_new_products_price, p.products_price) AS final_price,IF(p.products_model = NULL, -1, p.products_model) 
as codprod FROM {0} p LEFT JOIN {1} s ON p.products_id = s.products_id LEFT JOIN {2} m ON 
p.manufacturers_id = m.manufacturers_id,{3} pd,{4} p2c,{5} c,{6} cd WHERE p.products_status=1 AND p.master_categories_id = c.categories_id 
AND p2c.categories_id = c.categories_id AND c.categories_id = cd.categories_id AND p.products_id = p2c.products_id 
AND pd.products_id = p2c.products_id AND pd.language_id = {7} AND cd.language_id = {7}";

    // Generic - Print Header For Debug Informations
    function PrintHeaderForDebugInformations($platformName, $scriptVersion, $baseUrl, $imagesUrl,
 $platformVersion)
    {
        parent::PrintHeaderForDebugInformations($platformName, $scriptVersion);
        if($this->DebugIsEnabled())
        {
            echo "<p><b>Base URL: </b>" .$baseUrl. "</p>";'

            echo "<p><b>Images Base URL: </b>" . $imagesUrl . "</p>";'

            if (isset($platformVersion) && ($platformVersion != ''))
            {
                echo "<p><b>Platform version: </b>" . $platformVersion . "</p>";
            }
        }
    }

    function GetListingRow($zencartProvider, $listingRowFromDb, $availability, $productDecription,$originalPrice,
 $finalPrice, $baseUrl, $reftracking, $catList, $siteImagesUrl, $shippingPrice)
    {
        // 8 -  products_name
        // 14 - brand
        // 0 -  products_id
        // 17 - codprod
        // 2 -  products_image
        $listingRow;
        if($this->DebugIsEnabled())
        {
             $listingRow = "<tr><td>" . $this->FixEncodingToUTF8($listingRowFromDb[8]) . "</td><td>" . 
$listingRowFromDb[14] . "</td><td>" . "N/A" . "</td><td>" . $this->FixEncodingToUTF8($productDecription) . 
"</td><td>" . round($originalPrice,2) .
 "</td><td>" . round($finalPrice,2) . "</td><td>" . $listingRowFromDb[0] . "</td><td>" . $baseUrl."index.php?
main_page=product_info&products_id=".$listingRowFromDb[0].$reftracking . "</td><td>" . $availability . "</td><td>" .
 $this->FixEncodingToUTF8($catList) . "</td><td>" . $siteImagesUrl .$listingRowFromDb[2] . "</td><td>" . $shippingPrice . "</td><td>" 
. $listingRowFromDb[16] ."</td></tr>";
        }
        else
        {
            $statement = $zencartProvider->pdoProvider->query("SELECT uri FROM ceon_uri_mappings WHERE 
main_page='product_info' AND current_uri=1 AND associated_db_id=".$listingRowFromDb[0], PDO::FETCH_BOTH);
	    if ($row = $statement->fetch()){
		$link=$baseUrl. substr($row[0],1);
            }else{
		$link=$baseUrl. "index.php?main_page=product_info&products_id=" .$listingRowFromDb[0]. $reftracking;
	    }
            $listingRow = $this->FixEncodingToUTF8($listingRowFromDb[8]) ."|". $listingRowFromDb[14] ."|". "N/A" . "|" . 
$this->FixEncodingToUTF8($productDecription) ."|". round($originalPrice,2) . "|" . round($finalPrice,2) ."|". $listingRowFromDb[0] ."|".
 $link ."|". $availability ."|". $this->FixEncodingToUTF8($catList) ."|". $siteImagesUrl .$listingRowFromDb[2] ."|". $shippingPrice . "|" .
 $listingRowFromDb[16] . " <endrecord>";
        }
        return $listingRow;
    }
...

Ricordiamoci di aggiungere la riga: require_once 'DbProviderBase.php'; che ci permette di recuperare alcune delle funzioni necessarie nel nostro file modificato.


  • Java

  • Php

  • Mysql

  • Apache ant

  • Eclipse

  • Spring

  • Hibernate

  • Netbeans

  • Debian

  • Linux

  • Maven