/** * Checks all items in order that are downloaded and returns a list of item_ids for items * that have no representations attached. * * @return array A list of item_ids for which no representations are defined. */ public function itemsWithNoDownloadableMedia() { if (!$this->getPrimaryKey()) { return null; } $o_db = $this->getDb(); $qr_res = $o_db->query("\n\t\t\tSELECT item_id, object_id\n\t\t\tFROM ca_commerce_order_items\n\t\t\tWHERE\n\t\t\t\tfullfillment_method = 'DOWNLOAD' AND order_id = ?\n\t\t", (int) $this->getPrimaryKey()); $va_object_ids = array(); while ($qr_res->nextRow()) { $va_object_ids[$qr_res->get('object_id')] = true; } $va_object_ids = array_keys($va_object_ids); $qr_res->seek(0); $t_object = new ca_objects(); $va_rep_counts = $t_object->getMediaCountsForIDs($va_object_ids); $va_items_with_no_downloadable_media = array(); while ($qr_res->nextRow()) { $vn_object_id = $qr_res->get('object_id'); if (!isset($va_rep_counts[$vn_object_id]) || !$va_rep_counts[$vn_object_id]) { $va_items_with_no_downloadable_media[$qr_res->get('item_id')] = true; } } return array_keys($va_items_with_no_downloadable_media); }