This guide will give you information about extending the Shopware Connect Plugin (SwagConnect).
You could download and change the plugin directly, but we highly recommend not doing so. This will most likely lead to problems in the future, as your plugin is not capable of receiving updates. On every plugin release - probably every few weeks - you would have to check your plugin and adopt the changes. There is a better solution to changing the plugin code: Extend the plugin by using events.
In many cases, we are using standard Shopware Events. But we also throw new Events for important actions. This way you can manipulate orders before they are being saved, add or extract additional data from products or start your own workflows after a order has been placed. Here is a full list of the events we are currently supporting:
|fixBasketForConnect||Connect_Merchant_Create_Order_Before||Notify||Basket $shopwareBasket, Order $connectOrder||fired before the order is created. Dev can add some extra logic here|
|getProducts||Connect_Supplier_Get_Products_Filter_Source_IDS||Filter||array $sourceIds||is fired before sourceIds are submitted to helper function. Here you can exclude SKUs from Export.|
|getProducts||Connect_Supplier_Get_All_Products_Before||Notify||array $products||is fired before Products are transfered to connect-instance. For Example you can here use the customAttribute property of the Product Struct to extend it with your own logic.|
|getConnectProduct||Connect_Supplier_Get_Single_Product_Before||Notify||array $product||is fired before the all products event. It's nearly the same like getting all products. But you can prepare every single product before they are returned as an array to be transfered to the connect-instance.|
|buy||Connect_Supplier_Buy_Before||Notify||Order $order||is fired before the Shopware-Order is saved to database|
|updatePaymentStatus||Connect_Supplier_Update_PaymentStatus_Before||Notify||Order $order, PaymentStatus $paymentStatus||is fired before the Shopware-Order with the new PaymentStatus is saved to database|
|calculateShippingCosts||Connect_Supplier_Get_Shipping_After||Notify||Shipping $shipping, Order $order||is fired before the already calculated Shipping-Struct ist returned|
|reserve||Connect_Supplier_Reservation_Before||Notify||Order $order||is fired if the method is called|
|insertOrUpdate||Connect_Merchant_Saving_ArticleAttribute_Before||Notify||Attribute $connectAttribute||this event is fired before the Article-Attribute Object is persisted to database|
|insertOrUpdate||Connect_ProductToShop_InsertOrUpdate_Before||Filter||Product $product||this event is fired at the top of the function if only the product is passed.|
|insertOrUpdate||Connect_Merchant_Get_Article_Detail_After||Filter||ProductDetail $detail||this event is fired after the productDetails are loaded.|
|delete||Connect_Merchant_Delete_Product_Before||Notify||ProductDetail $articleDetail||this event is fired before the article will be deleted|
|update||Connect_Merchant_Update_GeneralProductInformation_Before||Notify||$shopId, $sourceId, ProductUpdate $product||this event is fired before general Product informations are updated|
|changeAvailability||Connect_Merchant_Update_ProductAvailability_Before||Notify||$shopId, $sourceId, $availability||In this function only the stock is updated. The dev can add some extra logic before or can quit the functionality.|
|makeMainVariant||Connect_Merchant_Update_ProductMainVariant_Before||Notify||$articleId, $articleDetailId||In this function the mainVariant of a product is changes. The dev can add some extra logic before or can quit the functionality.|
|buy||Connect_Subscriber_OrderReservation_OrderFilter||Filter||Order $order||If an order is triggered by a merchant shop the order can be accessed by this event.|
|reserveConnectProductsOnCheckoutFinish||Connect_Components_ProductFromShop_Buy_OrderFilter||Filter||Order $order||The supplier shop can read the order from the merchant shop and access the custom attributes.|
These events are just like basic Shopware events, so you can use them as described in the Shopware DevDocs.
Here you find all example plugins for the connect plugin.