Skip to content

Commit

Permalink
Improved naming
Browse files Browse the repository at this point in the history
  • Loading branch information
casperbakker committed Apr 29, 2019
1 parent a6e04f7 commit 5b99d44
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 49 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Picqer
Copyright (c) 2019 Picqer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Model/Sales/Active.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Picqer\Webhooks\Model\Sales;
namespace Picqer\Magento2\Model\Sales;

class Active implements \Magento\Framework\Option\ArrayInterface
{
Expand Down
17 changes: 10 additions & 7 deletions Observer/SendWebhook.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Picqer\Webhooks\Observer;
namespace Picqer\Magento2\Observer;

use Magento\Framework\Event\ObserverInterface;

Expand All @@ -19,22 +19,25 @@ public function __construct(

public function execute(\Magento\Framework\Event\Observer $observer)
{
$active = $this->_scopeConfig->getValue('picqer_webhook_options/general_settings/active');
if ($active != 1) {
$active = $this->_scopeConfig->getValue('picqer_integration_options/webhook_settings/active');
if ((int)$active !== 1) {
return;
}

$magentoKey = $this->_scopeConfig->getValue('picqer_webhook_options/general_settings/connection_key');
$domain = $this->_scopeConfig->getValue('picqer_webhook_options/general_settings/picqer_domain');
$subDomain = $this->_scopeConfig->getValue('picqer_integration_options/webhook_settings/picqer_subdomain');
$magentoKey = $this->_scopeConfig->getValue('picqer_integration_options/webhook_settings/connection_key');

if (empty($subDomain) || empty($magentoKey)) {
return; // Not fully configured
}

$order = $observer->getEvent()->getOrder();

$orderData = [];
$orderData['increment_id'] = $order->getIncrementId();
$orderData['picqer_magento_key'] = $magentoKey;
$orderData = json_encode($orderData);

$this->_curl->addHeader("Content-Type", "application/json");
$this->_curl->post('https://' . $domain . '.picqer.com/webshops/magento2/orderPush/' . $magentoKey, $orderData);
$this->_curl->post('https://' . $subDomain . '.picqer.com/webshops/magento2/orderPush/' . $magentoKey, json_encode($orderData));
}
}
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
### Picqer Extended Integration for Magento 2
----


# Picqer Extended Integration for Magento 2
Magento 2 Extensions for Picqer.


----
### Installation:


## Installation:
This project can easily be installed through Composer.

`composer require picqer/magento2-plugin`

### Activate module

## Activate module
1. Log onto your Magento 2 admin account and navigate to Stores > Configuration > Picqer > Webhooks
2. Fill out the general configuration information:
+ Active: Yes
+ Picqer Subdomain: is the prefix of your domain name. If you log on to 'my-shop.picqer.com', then fill in 'my-shop'.
+ Connection Key: can be found in Picqer > Settings > Webshops > Magento shop. Copy and paste in this field.
+ Picqer Domain: is the prefix of your domain name. If you log on to 'test.picqer.com', then fill in 'test'.

Orders will now be pushed to Picqer immediately.

Orders updates will now be pushed to Picqer immediately.
15 changes: 6 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@
"picqer",
"magento2"
],
"homepage": "https://github.com/picqer/magento2-plugin",
"license": "MIT",
"require": {
"php": ">=5.6.0"
"php": ">=5.6.0",
"ext-curl": "*",
"ext-json": "*"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/picqer/magento2-plugin"
}
],
"authors": [
{
"name": "Casper Bakker",
"name": "Anna van Brecht",
"email": "[email protected]"
}
],
"autoload": {
"files": ["registration.php"],
"psr-4": {
"Picqer\\Webhooks\\" : ""
"Picqer\\Magento2\\" : ""
}
}
}
20 changes: 10 additions & 10 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
<tab id="picqer" translate="label" sortOrder="10">
<label>Picqer</label>
</tab>
<section id="picqer_webhook_options" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<section id="picqer_integration_options" translate="label" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<class>separator-top</class>
<label>Webhooks</label>
<label>Integration</label>
<tab>picqer</tab>
<resource>Picqer_Webhooks::webhooks_config</resource>
<group id="general_settings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<resource>Picqer_Integration::webhooks_config</resource>
<group id="webhook_settings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>General Configuration</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Active</label>
<source_model>Picqer\Webhooks\Model\Sales\Active</source_model>
<source_model>Picqer\Magento2\Model\Sales\Active</source_model>
</field>
<field id="connection_key" translate="label" type="text" sortOrder="10" showInDefault="3" showInWebsite="0" showInStore="0">
<label>Connection Key</label>
<field id="picqer_subdomain" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Picqer subdomain</label>
</field>
<field id="picqer_domain" translate="label" type="text" sortOrder="10" showInDefault="4" showInWebsite="0" showInStore="0">
<label>Picqer Domain</label>
<field id="connection_key" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Connection key</label>
</field>
</group>
</section>
Expand Down
7 changes: 3 additions & 4 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0"?>
<config>
<default>
<picqer_webhook_options>
<general_settings>
</general_settings>
</picqer_webhook_options>
<picqer_integration_options>
<webhook_settings />
</picqer_integration_options>
</default>
</config>
2 changes: 1 addition & 1 deletion etc/events.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_save_after">
<observer name="picqer_webhooks_sales_order_save_after" instance="Picqer\Webhooks\Observer\SendWebhook" />
<observer name="picqer_webhooks_sales_order_save_after" instance="Picqer\Magento2\Observer\SendWebhook" />
</event>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Picqer_Webhooks" setup_version="1.0.0">
<module name="Picqer_Integration" setup_version="1.0.0">
<sequence>
<module name="Magento_Webapi" />
</sequence>
Expand Down
2 changes: 1 addition & 1 deletion registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Picqer_Webhooks', __DIR__);
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Picqer_Integration', __DIR__);

0 comments on commit 5b99d44

Please sign in to comment.