erkineren/shopwarebot

Shopware 后端机器人

v1.1 2019-02-12 09:58 UTC

This package is auto-updated.

Last update: 2024-09-25 09:30:06 UTC


README

Shopware Bot 是一个库,可以将您的后端转换为类似 REST API。使用此库,您可以执行一些内置 Shopware REST API 不支持的某些操作。

  • 创建发票和发货标签
  • 管理 pickware 插件库存活动
  • 搜索订单、文章、用户等。

目前,以下模块可用

  • ArticleModule
  • CustomerModule
  • DhlModule
  • DpdModule
  • ImportExportModule
  • LogModule
  • OrderModule
  • PickwareModule
  • PluginsModule

安装

$ composer require erkineren/shopwarebot

快速开始

use ShopwareBot\ShopwareBot;

require_once 'vendor/autoload.php';

$shop_url = "http://shopware.dev";
$username = 'user';
$password = 'password';

$bot = ShopwareBot::getInstance($shop_url);

try {
    // login to backend
    $bot->login($username, $password);
} catch (\ShopwareBot\Exceptions\CsrfException $e) {
    die($e->getMessage());
}

// Orders
$order = $bot->getOrderModule()->getOrderByNumber('12345');
$orders = $bot->getOrderModule()->getList($filter);

// Document
$bot->getOrderModule()->generateDocumentInvoice($orderId);
$bot->getOrderModule()->generateDocumentDeliveryNote($orderId);
$bot->getOrderModule()->generateDocumentCreditNote($orderId);
$bot->getOrderModule()->generateDocumentReversalInvoice($orderId);
$bot->getOrderModule()->generateDocument($orderId, $documentType); // custom document

// Customers
$bot->getCustomerModule()->getCustomerById($id);
$bot->getCustomerModule()->getCustomerByNumber($number);
$bot->getCustomerModule()->getCustomersByEmail($email);
$bot->getCustomerModule()->getCustomersByFirstname($firstname);
$bot->getCustomerModule()->getCustomersByFirstname($firstname);
$bot->getCustomerModule()->getCustomersByCustomerGroup($groupName);
$bot->getCustomerModule()->getCustomersByNumber($customernumbers);
$bot->getCustomerModule()->search($q);
$bot->getCustomerModule()->getBy($property, $value);
$bot->getCustomerModule()->getList($filter);
$bot->getCustomerModule()->getDetail($customerID);
$bot->getCustomerModule()->getUserAddressList($customerId);
$bot->getCustomerModule()->getUserOrders($customerID);
$bot->getCustomerModule()->getOrderChart($customerID);
$bot->getCustomerModule()->getUserPickwareArticles($customerID);
$bot->getCustomerModule()->delete($userId);

// Cache
$bot->getCacheModule()->clearShopCache();

// Logs
$bot->getLogModule()->createLog('Some logged data');


// ImportExport Plugin
$bot->getImportExportModule()->getProfiles();
$bot->getImportExportModule()->getProfiles();
$bot->getImportExportModule()->prepareExport($data);
$bot->getImportExportModule()->exportPartially(ImportExportModule::ARTICLES_COMPLETE, $limit); // for big data
$bot->getImportExportModule()->download($filename, 'files/saveto.csv');


// Pickware DPD,DHL adapters plugins
$bot->getDpdModule()->getShippingOrderData($orderId);
$bot->getDpdModule()->getAllLabels($orderId);
$bot->getDpdModule()->getTrackingUrls($trackingCodes);
$bot->getDpdModule()->getCountries();
$bot->getDpdModule()->getAllConfigurations();
$bot->getDpdModule()->getProducts();
$bot->getDpdModule()->getOrderConfigData($shopId);
$bot->getDpdModule()->calculateShippingWeight($orderId);
$bot->getDpdModule()->getMergedLabelsForOrder($orderId);
$bot->getDpdModule()->getLabelPdf($code);
$bot->getDpdModule()->getReturnLabelPdf($code);
// create shipping label
$bot->getDpdModule()->createLabel([
                'orderId' => $orderId,
                'detailsFirstName' => $address['firstname'],
                'detailsLastName' => $address['lastname'],
                'detailsStreet' => $address['street'],
                'detailsStreetNumber' => $address['no'],
                'detailsZipCode' => $address['postalcode'],
                'detailsCity' => $address['city'],
                'detailsStateId' => 0,
                'detailsCountryId' => $country['id'],
                'detailsEmail' => $address['email'],
                'packagingWeight' => 5
            ]);

// get shipping label that created from DPD plugin
ob_clean();
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=" . $code . ".pdf");
echo $bot->getDpdModule()->getLabelPdf($code);
die;


// Pickware ERP Plugin
$bot->getPickwareModule()->saveIncomingStock($articleDetailId,$binLocationId,$warehouseId,$incomingStock);
$bot->getPickwareModule()->saveIncomingStock($articleDetailId,$binLocationId,$warehouseId,$incomingStock);
$bot->getPickwareModule()->getStockList();
$bot->getPickwareModule()->getStockListByOrderDetailId();
$bot->getPickwareModule()->getStockListByUserId();
$bot->getPickwareModule()->getStockListByComment();
$bot->getPickwareModule()->getStockListByType();


// Plugins
$bot->getPluginsModule()->isPluginActive($technicalName_or_Label);
$bot->getPluginsModule()->getActivePlugins();
$bot->getPluginsModule()->getLocalList();

// Articles
$bot->getArticleModule()->deleteProduct($Detail_id);

待办事项

  • 添加更多模块

许可证

GPL-3.0+