• 23-10-2021, 00:26:17
    #1
    Daha önceden (profesyonel olarak yazılmamış) yapılan Cimri ile basit ürün entegrasyon kodları (ana dizininize atın, URL si php dosyanız direkt olarak)
    <?php 
    $db_host        = 'localhost';
    $db_user        = 'DB K.ADI';
    $db_pass        = 'ŞİFRE';
    $db_database    = 'DB ADI';
    try {
        $dsn = 'mysql:host=' . $db_host . ';dbname=' . $db_database;
        $db = new PDO($dsn, $db_user, $db_pass);
    } catch ( PDOException $e ){
         print $e->getMessage();
         exit();
    }
    $xml = new SimpleXMLElement('<MerchantItems xmlns="http://www.cimri.com/schema/merchant/upload" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>');
    $urunler = $db->query("SELECT OP.product_id,OP.model,OP.quantity,OP.image,OP.price,OD.name,OD.description FROM `oc_product` OP LEFT JOIN oc_product_description OD ON(OD.product_id=OP.product_id) WHERE OP.quantity > 0 AND OP.date_available < NOW()");
                foreach($urunler as $u){
                    if($u['image'] != ''){
                    $urun = $xml->addChild('MerchantItem');
                    $urun->addChild('merchantItemId', htmlspecialchars($u['product_id']));
                    $urun->addChild('merchantItemCategoryId', htmlspecialchars(5814));
                    $urun->addChild('merchantItemCategoryName',htmlspecialchars(strip_tags(html_entity_decode('CİMRİ KATEGORİ ADI'),'<IMG><br><p><u><b>')));
                    $urun->addChild('brand', htmlspecialchars('MARKA'));
                    $urun->addChild('model', htmlspecialchars($u['model']));
                    $urun->addChild('itemTitle', htmlspecialchars($u['name']));
                    $urun->addChild('merchantItemField', htmlspecialchars("Tüm ürünlerde ücretsiz kargo!"));
                    $urun->addChild('itemUrl', htmlspecialchars('https://www.siteadi.com/index.php?route=product/product&product_id='.$u['product_id']));
                    
                    $urun->addChild('priceEft', htmlspecialchars($u['price']));
                    $urun->addChild('pricePlusTax', htmlspecialchars($u['price']));
                    $urun->addChild('itemUrlMobile', htmlspecialchars('https://www.siteadi.com/index.php?route=product/product&product_id='.$u['product_id']));
                    $urun->addChild('itemImageUrl', htmlspecialchars('https://www.siteadi.com/image/'.$u['image']));
                    $urun->addChild('shippingFee', htmlspecialchars(0));
                    $urun->addChild('stockStatus', htmlspecialchars($u['quantity']));
                    $urun->addChild('stockDetail', htmlspecialchars('  '));
                    $urun->addChild('shippingDay', htmlspecialchars('1'));
                    $urun->addChild('shippingDetail', htmlspecialchars('KARGO DETAYI'));
                    $urun->addChild('typeOfWarranty', htmlspecialchars('0'));
                    $urun->addChild('warrantyPeriod', htmlspecialchars('0'));
                    
                    }
                }
        
    header('Content-type: text/xml');
    print($xml->asXML());
    ?>
  • 07-04-2022, 17:32:03
    #2
    Bu kodu kendi sitemiz için kullanılabilir hale nasıl getirebiliriz?