Jump to content
Alliner

XML Položka "DELIVERY_DATE" Heureka

Recommended Posts

Jako základ jsem použil část kódu (bohužel už nevím od koho) a upravil pro Heureku. Funguje pod PS 1.4.6.2. Jiné verze nevím.

 

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
$number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 5000);
$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 1);
$products = Product::getProducts((int)($cookie->id_lang), 0, ($number > 5000 ? 5000 : $number), $orderBy, $orderWay, $id_category, true);
$currency = new Currency((int)($cookie->id_currency));
$affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : '');
$manufacturer = Manufacturer::getManufacturers(false, (int)($cookie->id_lang));
foreach ($manufacturer as $key => $row) {
 $id  = $row['id_manufacturer'];
 $name = $row['name'];
 $man[$id][] = $name;
 $reference[$key] = $row['product_reference'];
}
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
?>
<SHOP>
 <NAME>Lucishop.cz.cz</NAME>
 <URL>http://www.lucishop.cz</URL>
<?php
   foreach ($products AS $product)
   {
    $image = Image::getImages((int)($cookie->id_lang), $product['id_product']);
    echo "\t\t<SHOPITEM>\n";
    echo "\t\t\t<ITEM_ID>".$product['reference']."</ITEM_ID>\n";	    
    $productName = $product['name'];
    $productName = str_replace("&", "a", $productName);
    echo "\t\t\t<PRODUCTNAME>".$productName."</PRODUCTNAME>\n";
    echo "\t\t\t<PRODUCT>".$productName."</PRODUCT>\n";
    $productDescription = strip_tags($product['description']);
    echo "\t\t\t<DESCRIPTION>".$productDescription."</DESCRIPTION>\n";
    echo "\t\t\t<URL>".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang))).$affiliate."</URL>\n";
    if (is_array($image) AND sizeof($image))
    {
	    $imageObj = new Image($image[0]['id_image']);
	    echo "\t\t\t<IMGURL>"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-large.jpg</IMGURL>\n";
	    $cdata = false;
    }
    $price = $product['price'];
    $rounded_price = sprintf("%0.2f", round($price, 2));
    echo "\t\t\t<PRICE_VAT>".$rounded_price."</PRICE_VAT>\n";
    $manId = $product['id_manufacturer'];
    echo "<MANUFACTURER>".$man[$manId][0]."</MANUFACTURER>";
    $cats= Db::getInstance()->ExecuteS('
    SELECT '._DB_PREFIX_.'category_lang.name  
    FROM '._DB_PREFIX_.'category_product LEFT JOIN  '._DB_PREFIX_.'category_lang ON
    '._DB_PREFIX_.'category_product.id_category =  '._DB_PREFIX_.'category_lang.id_category LEFT JOIN  '._DB_PREFIX_.'category ON
    '._DB_PREFIX_.'category_product.id_category =  '._DB_PREFIX_.'category.id_category	  
    WHERE '._DB_PREFIX_.'category_product.id_product = '.intval($product["id_product"]).' AND    '._DB_PREFIX_.'category_lang.id_lang= '.$cookie->id_lang.' AND    '._DB_PREFIX_.'category.active= 1 ORDER BY  '._DB_PREFIX_.'category.level_depth ASC '
    );
    $retval="";
    foreach($cats as $cat) {
	  $retval.=$cat["name"]." | ";
    }
    echo "\t\t\t<CATEGORYTEXT>".mb_substr($retval,0,mb_strlen($retval)-3)."</CATEGORYTEXT>\n";
    echo "\t\t\t<EAN>".$product['ean13']."</EAN>\n";
    echo "\t\t\t<DELIVERY_DATE>".$product['available_now']."</DELIVERY_DATE>\n";
    echo "\t\t</SHOPITEM>\n";
   }
?>
</SHOP>

Edited by Mogway (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Přídavkem ještě XML feed pro zbozi.cz :D

 

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
$number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 5000);
$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 1);
$products = Product::getProducts((int)($cookie->id_lang), 0, ($number > 5000 ? 5000 : $number), $orderBy, $orderWay, $id_category, true);
$currency = new Currency((int)($cookie->id_currency));
$affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : '');
$manufacturer = Manufacturer::getManufacturers(false, (int)($cookie->id_lang));
foreach ($manufacturer as $key => $row) {
 $id  = $row['id_manufacturer'];
 $name = $row['name'];
 $man[$id][] = $name;
 $reference[$key] = $row['product_reference'];
}
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
?>
<SHOP>
 <NAME>Lucishop.cz</NAME>
 <URL>http://www.lucishop.cz</URL>
<?php
foreach ($products AS $product)
{
	$image = Image::getImages((int)($cookie->id_lang), $product['id_product']);
	echo "\t\t<SHOPITEM>\n";	
	$productName = $product['name'];
	$productName = str_replace("&", "a", $productName);
	echo "\t\t\t<PRODUCT>".$productName."</PRODUCT>\n";
	echo "\t\t\t<CATEGORY>";
	$cats= Db::getInstance()->ExecuteS('
	SELECT '._DB_PREFIX_.'category_lang.name, '._DB_PREFIX_.'category_lang.id_category
	FROM '._DB_PREFIX_.'category_product LEFT JOIN '._DB_PREFIX_.'category_lang ON
	'._DB_PREFIX_.'category_product.id_category = '._DB_PREFIX_.'category_lang.id_category LEFT JOIN '._DB_PREFIX_.'category ON
	'._DB_PREFIX_.'category_product.id_category = '._DB_PREFIX_.'category.id_category	
	WHERE '._DB_PREFIX_.'category_product.id_product = '.intval($product["id_product"]).' AND '._DB_PREFIX_.'category_lang.id_lang= '.$cookie->id_lang.' AND '._DB_PREFIX_.'category.active= 1 ORDER BY '._DB_PREFIX_.'category.level_depth ASC '
	);
	foreach($cats as $cat) {
	  $retval="";
	  echo "\t\t\t\t<CATEGORYTEXT>";
	  $retval = $cat["name"];		
	  echo $retval;
	  echo "</CATEGORYTEXT>\n";
	  echo "\t\t\t\t<CATEGORYID>";
	  $retval = intval($cat["id_category"]);
	  echo $retval;
	  echo "</CATEGORYID>\n";
	}
	echo "</CATEGORY>\n";
	$productDescription = strip_tags($product['description']);
	echo "\t\t\t<DESCRIPTION>".$productDescription."</DESCRIPTION>\n";
	echo "\t\t\t<DESCRIPTION_SHORT>";
	$lenght = 50;
	$pos = mb_strpos($productDescription, '.', $lenght);
	if (!$pos)
	{
	  echo mb_substr($productDescription, 0, $lenght);
	}
	else
	{
	  if (mb_strlen($productDescription) < $lenght)
	  {
		echo $productDescription;
	  }
	  else
	  {
		echo mb_substr($productDescription, 0, $pos+1);
	  }
	}
	echo "</DESCRIPTION_SHORT>\n";
	echo "\t\t\t<URL>".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang))).$affiliate."</URL>\n";
	if (is_array($image) AND sizeof($image))
	{
		$imageObj = new Image($image[0]['id_image']);
		echo "\t\t\t<IMGURL>"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-large.jpg</IMGURL>\n";
		$cdata = false;
	}
	$price = $product['price'];
	$rounded_price = sprintf("%0.2f", round($price, 2));
	echo "\t\t\t<PRICE_VAT>".$rounded_price;
	echo "</PRICE_VAT>\n";
	echo "\t\t\t<AVAILABILITY>".$product['available_now']."</AVAILABILITY>\n";
	echo "\t\t</SHOPITEM>\n";
}
?>
</SHOP>

Share this post


Link to post
Share on other sites

Jako základ jsem použil část kódu (bohužel už nevím od koho) a upravil pro Heureku. Funguje pod PS 1.4.6.2. Jiné verze nevím.

 

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
$number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 5000);
$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 1);
$products = Product::getProducts((int)($cookie->id_lang), 0, ($number > 5000 ? 5000 : $number), $orderBy, $orderWay, $id_category, true);
$currency = new Currency((int)($cookie->id_currency));
$affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : '');
$manufacturer = Manufacturer::getManufacturers(false, (int)($cookie->id_lang));
foreach ($manufacturer as $key => $row) {
 $id  = $row['id_manufacturer'];
 $name = $row['name'];
 $man[$id][] = $name;
 $reference[$key] = $row['product_reference'];
}
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
?>
<SHOP>
 <NAME>Lucishop.cz.cz</NAME>
 <URL>http://www.lucishop.cz</URL>
<?php
foreach ($products AS $product)
{
	$image = Image::getImages((int)($cookie->id_lang), $product['id_product']);
	echo "\t\t<SHOPITEM>\n";
	echo "\t\t\t<ITEM_ID>".$product['reference']."</ITEM_ID>\n";		
	$productName = $product['name'];
	$productName = str_replace("&", "a", $productName);
	echo "\t\t\t<PRODUCTNAME>".$productName."</PRODUCTNAME>\n";
	echo "\t\t\t<PRODUCT>".$productName."</PRODUCT>\n";
	$productDescription = strip_tags($product['description']);
	echo "\t\t\t<DESCRIPTION>".$productDescription."</DESCRIPTION>\n";
	echo "\t\t\t<URL>".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang))).$affiliate."</URL>\n";
	if (is_array($image) AND sizeof($image))
	{
		$imageObj = new Image($image[0]['id_image']);
		echo "\t\t\t<IMGURL>"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-large.jpg</IMGURL>\n";
		$cdata = false;
	}
	$price = $product['price'];
	$rounded_price = sprintf("%0.2f", round($price, 2));
	echo "\t\t\t<PRICE_VAT>".$rounded_price."</PRICE_VAT>\n";
	$manId = $product['id_manufacturer'];
	echo "<MANUFACTURER>".$man[$manId][0]."</MANUFACTURER>";
	$cats= Db::getInstance()->ExecuteS('
	SELECT '._DB_PREFIX_.'category_lang.name  
	FROM '._DB_PREFIX_.'category_product LEFT JOIN  '._DB_PREFIX_.'category_lang ON
	'._DB_PREFIX_.'category_product.id_category =  '._DB_PREFIX_.'category_lang.id_category LEFT JOIN  '._DB_PREFIX_.'category ON
	'._DB_PREFIX_.'category_product.id_category =  '._DB_PREFIX_.'category.id_category	  
	WHERE '._DB_PREFIX_.'category_product.id_product = '.intval($product["id_product"]).' AND	'._DB_PREFIX_.'category_lang.id_lang= '.$cookie->id_lang.' AND	'._DB_PREFIX_.'category.active= 1 ORDER BY  '._DB_PREFIX_.'category.level_depth ASC '
	);
	$retval="";
	foreach($cats as $cat) {
	  $retval.=$cat["name"]." | ";
	}
	echo "\t\t\t<CATEGORYTEXT>".mb_substr($retval,0,mb_strlen($retval)-3)."</CATEGORYTEXT>\n";
	echo "\t\t\t<EAN>".$product['ean13']."</EAN>\n";
	echo "\t\t\t<DELIVERY_DATE>".$product['available_now']."</DELIVERY_DATE>\n";
	echo "\t\t</SHOPITEM>\n";
}
?>
</SHOP>

 

Zdravím,

konečně jsem našel script, který funguje v prestě 1.4.9 jak má. Díky za něj. Akorát bych potřeboval přidat podmínku, aby se zobrazovalo jen zboží, které má nastaveno v ps_product available_for_order 1

 

Pohrával jsem si s tím, ale bohužel se mi to nedaří vyfiltrovat. Přidával jsem podmínku if ($row['available_for_order'] = 1) za foreach ($products AS $product){ ale nějak mi to nefunguje.

 

Můžete mi pls někdo poradit?

Díky moc

Share this post


Link to post
Share on other sites

feed od SemTama funguje paradne a je to pekne prehledny, diky! pouzivam PS 1.4.7

 

akorat tu mam problem s <price_vat> ve feedu <cena_vcetne_dph>, mam obchod v CZK a v EUR a tadle polozka se mi meni ve feedu podle toho na jakou menu mam zrovna prepnuty obchod. Nevite jak to zapsat a tu cenu zafixovat jen napriklad pro CZK?

 

<CENA_VCETNE_DPH>'.($row['price']*1).'</CENA_VCETNE_DPH>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More