Arama Yap Mesaj Gönder
Biz Sizi Arayalım
+90
X
X
X
X

Knowledge Base

Homepage Knowledge Base General Hepsiburada Trendyol Bulk Product U...

Bize Ulaşın

Konum Halkalı merkez mahallesi fatih cd ozgur apt no 46 , Küçükçekmece , İstanbul , 34303 , TR

Hepsiburada Trendyol Bulk Product Upload: How to Do it with PHP?

With the rapid growth of e-commerce today, it is of great importance for businesses selling products on online platforms to list their products quickly and effectively. Leading e-commerce platforms in Turkey, such as Hepsiburada and Trendyol, allow sellers to upload their products in bulk, saving time and labor. This article will provide a detailed guide on how to perform bulk product uploads to Hepsiburada and Trendyol platforms using the PHP programming language.

1. Introduction

Bulk product upload is the process of transferring a large number of products to e-commerce platforms at once. This process is indispensable, especially for businesses with a wide product range. Instead of manually adding products one by one, uploading all product information to the platform via a CSV, Excel, or XML file saves time and minimizes errors. PHP is a widely used server-side scripting language for developing dynamic web applications. In this article, you will learn how to automate bulk product upload processes to Hepsiburada and Trendyol by leveraging the power of PHP.

2. Basic Concepts and Requirements

2.1. API (Application Programming Interface)

Platforms like Hepsiburada and Trendyol offer APIs so that sellers can integrate with their systems. APIs are interfaces that allow different software systems to communicate with each other. You can perform operations such as product upload, order management, and stock tracking via APIs. By examining the API documentation of Hepsiburada and Trendyol, you need to learn which endpoints (URLs) accept which data and how they are used.

2.2. Data Formats (CSV, Excel, XML, JSON)

Data formats such as CSV (Comma Separated Values), Excel (XLSX), or XML (Extensible Markup Language) are generally used for bulk product upload. These formats allow you to store product information in an organized manner and transfer it to the platform. JSON (JavaScript Object Notation) is a format frequently used for sending and receiving data via APIs.

2.3. PHP Libraries and Tools

When performing bulk product uploads with PHP, some libraries and tools can make your job easier:

  • cURL: Used to send HTTP requests and communicate with APIs.
  • Composer: A tool used to manage PHP dependencies.
  • PHPExcel/PhpSpreadsheet: Used to read and write Excel files.
  • XML Parser: Used to parse XML files.
  • JSON Encode/Decode: Used to process JSON data.

2.4. Required Accounts and Authorizations

You need to have a seller account on Hepsiburada and Trendyol and have the necessary authorizations for API access. You will need to obtain authentication information such as API keys or tokens and use them in your PHP code.

3. Hepsiburada Bulk Product Upload

3.1. Introduction to Hepsiburada API

Hepsiburada's API offers various endpoints for sellers to manage their products, track orders, and perform other operations. For the product upload process, you need to use the relevant endpoints specified in Hepsiburada's API documentation.

3.2. Data Preparation

To upload products to Hepsiburada, you need to prepare the product information in a specific format. Hepsiburada usually accepts data in CSV or Excel format. The following table provides an example of a typical product data format for Hepsiburada:

Product Name Category Description Price Stock Quantity Image URL Barcode
Smartphone Electronics Latest model smartphone 7999.99 100 https://example.com/telefon.jpg 1234567890
Laptop Electronics High-performance laptop 12999.99 50 https://example.com/laptop.jpg 0987654321

The columns in this table represent the product features required by Hepsiburada. When creating your data file, you should pay attention to the mandatory and optional fields specified in Hepsiburada's API documentation.

3.3. Reading CSV File with PHP

You can use the fgetcsv() function to read a CSV file with PHP. The following code example reads a CSV file and transfers the product information to an array:


<?php
$csvFile = 'urunler.csv';
$csv = array();

if (($handle = fopen($csvFile, "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $csv[] = $data;
    }
    fclose($handle);
}

// Printing CSV data
echo "<pre>";
print_r($csv);
echo "</pre>";
?>

This code opens a file named urunler.csv, reads each line, and transfers the comma-separated values to an array. You can then use this array to send a request to the Hepsiburada API.

3.4. Sending Request to Hepsiburada API

You can use the cURL library to upload products to the Hepsiburada API. The following code example shows how to send a request to upload a product to the Hepsiburada API:


<?php
$apiUrl = 'https://api.hepsiburada.com/products'; // Replace with the actual API URL
$apiKey = 'YOUR_API_KEY'; // Replace with your API key

$urunVerisi = array(
    'urunAdi' => 'New Product',
    'kategori' => 'Electronics',
    'aciklama' => 'New product description',
    'fiyat' => 999.99,
    'stokAdedi' => 50
);

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($urunVerisi));

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

echo "HTTP Code: " . $httpCode . "<br>";
echo "Response: " . $response . "<br>";

?>

This code sends a POST request to the Hepsiburada API. The content of the request includes product information in JSON format. Remember to replace YOUR_API_KEY with your own API key. The HTTP code and response will help you check if the request was successful.

3.5. Error Management and Logging

It is likely that you will encounter errors during the bulk product upload process. Therefore, it is important to implement error management and logging mechanisms. By catching errors, you can analyze their causes and develop solutions. Logging allows you to keep a record of errors and operations, making it easier to identify problems.

4. Trendyol Bulk Product Upload

4.1. Introduction to Trendyol API

Trendyol's API offers various endpoints for sellers to manage their products, track orders, and perform other operations. For the product upload process, you need to use the relevant endpoints specified in Trendyol's API documentation.

4.2. Data Preparation

To upload products to Trendyol, you need to prepare the product information in a specific format. Trendyol usually accepts data in CSV or Excel format. The following table provides an example of a typical product data format for Trendyol:

Product Name Category Code Brand Description Price Stock Quantity Image URL Barcode VAT Rate
Smart Watch 1001 XYZ Latest model smart watch 4999.99 75 https://example.com/saat.jpg 9876543210 18
Bluetooth Headset 1002 ABC High quality bluetooth headset 999.99 120 https://example.com/kulaklik.jpg 0123456789 18

The columns in this table represent the product attributes requested by Trendyol. When creating your data file, you should pay attention to the mandatory and optional fields specified in Trendyol's API documentation. Category codes are determined according to Trendyol's category tree, and it is important to use the correct category code.

4.3. Reading Excel File with PHP

You can use the PhpSpreadsheet library to read an Excel file with PHP. The following code example reads an Excel file and transfers the product information into an array:


<?php
require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\IOFactory;

$excelFile = 'urunler.xlsx';

$spreadsheet = IOFactory::load($excelFile);
$sheet = $spreadsheet->getActiveSheet();
$data = $sheet->toArray();

// Printing Excel data
echo "<pre>";
print_r($data);
echo "</pre>";
?>

This code opens a file named urunler.xlsx, reads each row, and transfers the cell values into an array. To use the PhpSpreadsheet library, you must first install it with Composer: composer require phpoffice/phpspreadsheet.

4.4. Sending Request to Trendyol API

To upload products to the Trendyol API, you can use the cURL library. The following code example shows how to send a request to upload a product to the Trendyol API:


<?php
$apiUrl = 'https://api.trendyol.com/products'; // Replace with the actual API URL
$supplierId = 'YOUR_SUPPLIER_ID'; // Replace with your Supplier ID
$username = 'YOUR_USERNAME'; // Replace with your username
$password = 'YOUR_PASSWORD'; // Replace with your password

$urunVerisi = array(
    'title' => 'New Product',
    'categoryId' => 1001,
    'brandId' => 123,
    'description' => 'New product description',
    'listPrice' => 1299.99,
    'salePrice' => 999.99,
    'stock' => 50
);

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Authorization: Basic ' . base64_encode($username . ':' . $password),
    'Trendyol-SupplierId: ' . $supplierId
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($urunVerisi));

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

echo "HTTP Code: " . $httpCode . "<br>";
echo "Response: " . $response . "<br>";

?>

This code sends a POST request to the Trendyol API. The content of the request includes product information in JSON format. Remember to replace YOUR_SUPPLIER_ID, YOUR_USERNAME, and YOUR_PASSWORD with your own information. The Trendyol API uses Basic Authentication, so you need to encrypt your username and password with base64.

4.5. Variant Management

Variant management is important on Trendyol for products with variants (e.g., clothing items with different sizes or color options). You need to create a separate product record for each variant and specify the variant attributes.

5. Real-Life Examples and Case Studies

5.1. How a Small Business Grew with Bulk Product Uploading

A small crafts business decided to sell their products on Hepsiburada and Trendyol. Initially, they tried to add products manually, but this was very time-consuming and tiring. Later, by developing bulk product upload scripts with PHP, they started listing their products much faster and more efficiently. As a result, their sales increased significantly and their business grew.

5.2. How a Large Retail Chain Solved Integration Problems

A large retail chain was struggling to integrate their existing ERP systems with Hepsiburada and Trendyol. Due to different data formats and API requirements, the integration process was very complex and costly. By developing a custom integration solution with PHP, they managed to automatically transfer product information from their ERP systems to Hepsiburada and Trendyol. As a result, they reduced integration costs and increased their operational efficiency.

6. Visual Explanations

Schema: Bulk Product Uploading Process

[ERP System] --(Data Transfer)--> [PHP Script] --(API Requests)--> [Hepsiburada/Trendyol]

This schema shows the basic steps of the bulk product uploading process. Product data from the ERP system is processed by the PHP script and sent to the Hepsiburada or Trendyol API.

7. Frequently Asked Questions

  • Question: How to get access to Hepsiburada and Trendyol APIs? Answer: You need to have a seller account on Hepsiburada and Trendyol and apply for API access. After your application is approved, you can obtain authentication information such as API keys or tokens.
  • Question: Which data formats are supported? Answer: Generally, CSV, Excel (XLSX), and XML formats are supported. However, each platform may have its own requirements, so it is important to review the API documentation.
  • Question: How should error management be done? Answer: You can catch errors using try-catch blocks in PHP and keep a record of errors using logging mechanisms. You can also detect errors by checking API responses.
  • Question: How to upload products with variants? Answer: For products with variants, you need to create a separate product record for each variant and specify the variant properties (e.g., size, color).
  • Question: Are there rate limits on API requests? Answer: Yes, platforms like Hepsiburada and Trendyol may limit the number of requests made to their APIs. Therefore, you need to optimize your requests and comply with rate limits.

8. Conclusion and Summary

This article provides a detailed guide on how to perform bulk product uploads to Hepsiburada and Trendyol platforms using the PHP programming language. Topics such as accessing APIs, preparing data, reading data files with PHP, sending requests to APIs, error management, and logging are covered. Bulk product upload allows e-commerce businesses to list their products quickly and efficiently, thus saving time and labor. By using the information in this article, you can develop your own bulk product upload scripts and optimize your e-commerce operations.

 

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(2115 times viewed / 64 people found it helpful)

Call now to get more detailed information about our products and services.

Top