Last active
November 7, 2018 11:12
-
-
Save bluvertigo/8fe35ec028c4fcc8ad288f4d1d60a2d3 to your computer and use it in GitHub Desktop.
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
<? | |
declare(strict_types=1); | |
use Magento\Sales\Model\Order\Item; | |
use Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory as ItemCollectionFactory; | |
class Example | |
{ | |
/** | |
* @var ItemCollectionFactory | |
*/ | |
private $itemCollectionFactory; | |
public function __construct( | |
ItemCollectionFactory $itemCollectionFactory | |
) { | |
$this->itemCollectionFactory = $itemCollectionFactory; | |
} | |
/** | |
* Restituisce un array di order items da attivare | |
* @return Item[] | |
*/ | |
public function execute(): array | |
{ | |
$collection = $this->itemCollectionFactory->create(); | |
$collection->getSelect() | |
->distinct(true) | |
->joinInner( | |
'tab1', | |
'parent_id = order_id', | |
'' | |
)->joinLeft( | |
'tabella2', | |
'order_item_id = entity_id' | |
)->where('activation_id IS NULL AND gl_activable = 1'); | |
return $collection->getItems(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment