* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link https://www.temando.com/ */ class ShipmentCollectionLoadObserver implements ObserverInterface { /** * Add the shipment status column, aliased with namespace prefix to avoid collisions. * * @param Observer $observer * @return void */ public function execute(Observer $observer) { $collection = $observer->getData('collection'); if ($collection instanceof ShipmentCollection || $collection instanceof OrderShipmentCollection) { $index = 'shipment_status'; $alias = 'temando_shipment_status'; try { $collection->getSelect()->columns([$alias => $index]); $where = $collection->getSelect()->getPart(\Zend_Db_Select::WHERE); $collection->getSelect()->setPart(\Zend_Db_Select::WHERE, str_replace($alias, $index, $where)); } catch (\Zend_Db_Select_Exception $exception) { return; } } } }