Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
[BUG] Fix wrong configuration on last change
Browse files Browse the repository at this point in the history
  • Loading branch information
tuyennn committed May 26, 2019
1 parent bf4e8e3 commit c23dc3f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 23 deletions.
63 changes: 63 additions & 0 deletions Plugin/Ui/DataProvider/Product/DataProviderPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace GhoSter\AutoInstagramPost\Plugin\Ui\DataProvider\Product;

use Magento\Framework\DB\Select;
use Magento\Framework\Api\Filter;
use GhoSter\AutoInstagramPost\Ui\DataProvider\Product\DataProvider;

/**
* Class DataProviderPlugin
* @package GhoSter\AutoInstagramPost\Plugin\Ui\DataProvider\Product
*/
class DataProviderPlugin
{
/**
* @param DataProvider $subject
* @param callable $proceed
* @param Filter $filter
* @throws \Zend_Db_Select_Exception
*/
public function aroundAddFilter(
DataProvider $subject,
callable $proceed,
Filter $filter
) {

$proceed($filter);

if ($filter->getField() == 'posted_to_instagram') {
$collection = $subject->getCollection();
$select = $collection->getSelect();
$partsFrom = $select->getPart(Select::FROM);

if (isset($partsFrom['at_posted_to_instagram'])) {
if ($whereParts = $select->getPart(Select::WHERE)) {
foreach ($whereParts as $key => $wherePartItem) {
$whereParts[$key] = $this->_replaceFilterCondition($wherePartItem);
}
$select->setPart(Select::WHERE, $whereParts);
}
}
}
}

/**
* Replace table alias in condition string
*
* @param string|null $conditionString
* @return string|null
*/
protected function _replaceFilterCondition($conditionString)
{
if ($conditionString === null) {
return null;
}

if ($conditionString == "(at_posted_to_instagram.value = '0')") {
$conditionString = "(at_posted_to_instagram.value = '0' OR at_posted_to_instagram.value IS NULL)";
}

return $conditionString;
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This Magento 2 extension Auto Instagram Post allows you add your products immedi
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bf0757d0063e489eb3bff2479964fce2)](https://www.codacy.com/app/GhoSterInc/AutoInstagramPost?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=tuyennn/AutoInstagramPost&amp;utm_campaign=Badge_Grade)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/thinghost)
![Version 1.1.5](https://img.shields.io/badge/Version-1.1.5-green.svg)
![Version 1.1.5](https://img.shields.io/badge/Version-1.1.6-green.svg)

---
## [![Alt GhoSter](http://thinghost.info/wp-content/uploads/2015/12/ghoster.png "thinghost.info")](http://thinghost.info) Overview
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

},
"type": "magento2-module",
"version": "1.1.5",
"version": "1.1.6",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
3 changes: 3 additions & 0 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@
<type name="Magento\Backend\Model\Menu\Builder">
<plugin name="GhoSter_AutoInstagramPost::disable_manage_menu_depends_module_status" type="GhoSter\AutoInstagramPost\Plugin\Model\Menu\BuilderPlugin"/>
</type>
<type name="GhoSter\AutoInstagramPost\Ui\DataProvider\Product\DataProvider">
<plugin name="GhoSter_AutoInstagramPost::fix_filter_ui_component_boolean" type="GhoSter\AutoInstagramPost\Plugin\Ui\DataProvider\Product\DataProviderPlugin"/>
</type>
</config>
40 changes: 20 additions & 20 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
<resource>GhoSter_AutoInstagramPost::config</resource>
<group id="general" translate="label" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>General Settings</label>
<field id="enable" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable Auto Instagram</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="username" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Username(Instagram Account)</label>
<frontend_class>required-entry</frontend_class>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>required-entry</validate>
</field>
<field id="password" translate="label" type="password" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>required-entry</validate>
</field>
Expand All @@ -35,7 +35,7 @@
<label/>
<comment><![CDATA[This action will try to use your provided data to login with Instagram API]]></comment>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="upload_image_id" translate="label comment" type="image" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
Expand All @@ -44,51 +44,51 @@
<base_url type="media" scope_info="1">instagram</base_url>
<comment><![CDATA[Default Image will be uploaded when product have no Image available. Recommended 800x800 px]]></comment>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>required-entry</validate>
</field>
<field id="enable_observer" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Allow auto posting to Instagram after Saving Product</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
</field>
</group>
<group id="comment_hashtag" translate="label" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Images Description Settings</label>
<field id="enable" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="enabled" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable Auto Hashtag and Description</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="*/general/enable">1</field>
<field id="*/general/enabled">1</field>
</depends>
</field>
<field id="product_description" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Add Product Description to Post</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Description on Instagram Post should be generated from product description]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="category_hashtag" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Add Categories Name as Hashtags</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Hashtag on Instagram Post should be generated from categories which product belongs]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="enable_custom" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Add Custom Hashtags</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="hashtag" translate="label" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
Expand All @@ -97,17 +97,17 @@
<backend_model>GhoSter\AutoInstagramPost\Model\Config\Backend\Hashtag</backend_model>
<comment><![CDATA[Hashtag on Instagram Post should include these custom, no need to add # before hashtag, value should be stripped and remove spaces]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
<field id="enable_custom">1</field>
</depends>
</field>
<field id="description_template" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Description Template</label>
<comment><![CDATA[{{CUSTOMHASTAG}} {{CATEGORYHASHTAG}} {{PRODUCTDESC}} {{PRODUCTNAME}}</br>Instagram caption character limit: 2,200 characters</br>Instagram hashtag limit: 30 hashtags</br>Instagram bio character limit: 150 characters]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
</group>
Expand All @@ -117,7 +117,7 @@
<label>Enable Scheduled Auto Post</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="*/general/enable">1</field>
<field id="*/general/enabled">1</field>
</depends>
</field>
<field id="time" translate="label" type="time" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
Expand All @@ -137,7 +137,7 @@
<field id="limit" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Limit Number of Posts</label>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>validate-zero-or-greater</validate>
</field>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?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="GhoSter_AutoInstagramPost" setup_version="1.1.5"/>
<module name="GhoSter_AutoInstagramPost" setup_version="1.1.6"/>
</config>

0 comments on commit c23dc3f

Please sign in to comment.