This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from tuyennn/feature/fix-wrong-configuration
[BUG] Fix wrong configuration on last change
- Loading branch information
Showing
6 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |