/** * This method retrieves the Inventory Watchlist page data from the DB, formats it for the front-end, and (optionally) translates it for the locale. * @param array $warehouseIds Default: array( 1,4 ) * @param string $locale Default: en_US * @return boolean|array * @see ItemAvailabilityTimes::getInventoryWatchlistItems() * @see ProductsController::$itemAvailabilityIdToInventoryWatchlistIndividualStatus * @see ProductsController::$itemAvailabilityIdToInventoryWatchlistCollectionStatus * @see BackOrderRestock::getItemName() */ protected function processInventoryWatchlistItems(array $warehouseIds = array(1), $locale = 'en_US') { $return = false; $locale = trim((string) $locale); if (count($warehouseIds) && !empty($locale)) { // Validate Passed Parameters $backOrderRestockObject = new BackOrderRestock(); $return = array(); foreach ($this->ItemAvailabilityTimes->getInventoryWatchlistItems($warehouseIds) as $currentItem) { // Loop through Inventory Watchlist Items $backOrderRestockObject->sku = $currentItem['Item']['sku']; $currentItemTranslatedName = $backOrderRestockObject->getItemName($locale); $currentProductName = is_array($currentItemTranslatedName) && !empty($currentItemTranslatedName['Item']['name']) ? $currentItemTranslatedName['Item']['name'] : $currentItem['Item']['name']; if ($this->ItemsItems->find('count', array('conditions' => array('child_item_id' => $currentItem['Item']['id']))) > 0) { // Verify if Collection Status Required $currentCollectionStatus = $this->itemAvailabilityIdToInventoryWatchlistCollectionStatus[$currentItem['ItemAvailabilityTimes']['item_availability_id']]; } else { // Middle of Verify if Collection Status Required $currentCollectionStatus = 'NA'; } // End of Verify if Collection Status Required if (in_array($currentItem['Item']['sku'], array('US-11405-01', 'US-11405-02', 'US-11405-03'))) { // Hard-Coded SKUs with NO Collection Status -- Remove for Phase 2 $currentCollectionStatus = 'NA'; // @todo Remove this hard-coded block in Phase 2 - https://younique.attask-ondemand.com/task/view?ID=572a6a5b007df7a5df643924d8a46216 } // End of Hard-Coded SKUs with NO Collection Status -- Remove for Phase 2 $currentItemEstimatedDate = strtotime($currentItem['ItemAvailabilityTimes']['estimated_date']); $currentReturnItem = array('sku' => $currentItem['Item']['sku'], 'product' => $currentProductName, 'individual_status' => $this->itemAvailabilityIdToInventoryWatchlistIndividualStatus[$currentItem['ItemAvailabilityTimes']['item_availability_id']], 'collection_status' => $currentCollectionStatus, 'restock_date' => false !== $currentItemEstimatedDate ? date('m/j/Y', $currentItemEstimatedDate) : null, 'restock_date_unixtime' => false !== $currentItemEstimatedDate ? $currentItemEstimatedDate : null); $return[] = $currentReturnItem; } // End of Loop through Inventory Watchlist Items } // End of Validate Passed Parameters return $return; }