Skip to content

Instantly share code, notes, and snippets.

@bluvertigo
Last active November 7, 2018 11:12
Show Gist options
  • Save bluvertigo/8fe35ec028c4fcc8ad288f4d1d60a2d3 to your computer and use it in GitHub Desktop.
Save bluvertigo/8fe35ec028c4fcc8ad288f4d1d60a2d3 to your computer and use it in GitHub Desktop.
<?
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