Hi modMore-Community,
as I’m working on my first Commerce-Project, and I’m also a Gitify user, I wanted to make the two play well together.
The first thing I needed was Gitify-Configuration for the Commerce-Extra. After talking to Mark he pointed me to a XML Schema-File with all available objects. The file is located in /core/components/commerce/model/schema
and is named commerce.mysql.schema.xml. There are a lot of objects defined in this file… So I wrote a little parser-file (in PHP) that can be put in the same folder and iterates over the XML and extracts everything necessary:
<?php
/*
* Commerce-Gitify-Parser
* Copyright 2017 by Sebastian G. Marinescu
*/
$path = getcwd() . '/';
$xml = file_get_contents($path . 'commerce.mysql.schema.xml');
$root = new SimpleXMLElement($xml);
foreach($root->children() as $obj){
$className = $obj['class'];
$tableName = $obj['table'];
if (empty($tableName)) {
continue;
}
echo $tableName . ':';
echo "\n\t";
echo 'class: ' . $className;
echo "\n\t";
echo 'primary: id';
echo "\n";
}
I provided this parser as a Gist.
As the time of writing the Gitify-Config for Commerce looks something like this:
commerce_currency:
class: comCurrency
primary: id
package: commerce
service: Commerce
commerce_product:
class: comProduct
primary: id
commerce_product_bundle_product:
class: comProductBundleProduct
primary: id
commerce_order:
class: comOrder
exclude_keys:
- created_on
primary: id
commerce_order_item:
class: comOrderItem
primary: id
commerce_order_shipment:
class: comOrderShipment
primary: id
commerce_delivery_type:
class: comDeliveryType
primary: id
commerce_shipping_method:
class: comShippingMethod
primary: id
commerce_status:
class: comStatus
primary: id
commerce_status_change:
class: comStatusChange
primary: id
commerce_status_change_action:
class: comStatusChangeAction
primary: id
commerce_tax_group:
class: comTaxGroup
primary: id
commerce_tax_rule:
class: comTaxRule
primary: id
commerce_tax_rate:
class: comTaxRate
primary: id
commerce_order_item_tax_rate:
class: comOrderItemTax
primary: id
commerce_order_item_adjustment:
class: comOrderItemAdjustment
primary: id
commerce_order_log:
class: comOrderLog
primary: id
commerce_order_address:
class: comOrderAddress
primary: id
commerce_address:
class: comAddress
primary: id
commerce_order_message:
class: comOrderMessage
primary: id
commerce_transaction:
class: comTransaction
primary: id
commerce_payment_method:
class: comPaymentMethod
primary: id
commerce_module:
class: comModule
primary: id
commerce_coupon:
class: comCoupon
primary: id
commerce_coupon_usage:
class: comCouponUsage
primary: id
I’ve created a PR for the Docs, so in the future this will be documented in the right spot.
So after preparing the config I immediately tried it, but with no luck. As it turns out, the commerce-class comes as a service-class, which Gitify did not yet understand to load. After a little bit of dangling and debugging I understood the problem and introduced the “service” option into Gitify, which when provided, tries to load the service-class. The necessary changes to Gitify are waiting approval in a PR, but can also be seen or used in my fork on the “serviceload”-branch.
I hope this is at least interesting or maybe even helps somebody someday
With best regards,
Sebastian