I’m writing an observer that check every item in a order, at some point I get the items
foreach($order->getAllItems() as $item){
//do something
echo $item->getSku();
}
//output
sku-first
sku-first
sku-second
sku-second
but I get twice the same item with the same sku of course, where’s the catch? maybe in some configuration file?
I believe you want to use
getAllVisibleItems()instead ofgetAllItems().I believe getAllItems gets the configurable along with its associated simple product.