public function checkForDuplicates() { // show warning if duplicate products found $listingsModel = new WPLA_ListingsModel(); $duplicateProducts = $listingsModel->getAllDuplicateProducts(); // $duplicateASINs = $listingsModel->getAllDuplicateASINs(); $duplicateSKUs = $listingsModel->getAllDuplicateSKUs(); $msg = ''; // if ( ! empty($duplicateProducts) || ! empty($duplicateASINs) || ! empty($duplicateSKUs) ) { if (!empty($duplicateProducts) || !empty($duplicateSKUs)) { $duplicates_total = max(count($duplicateProducts), count($duplicateSKUs)); $msg .= '<p><b>' . sprintf(__('Warning: There are %s duplicate listings. Your action is required.', 'wpla'), $duplicates_total) . '</b>'; $msg .= ' <a href="#" onclick="jQuery(\'#wpla_dupe_details\').toggle();return false;" class="button button-small">' . __('Show duplicates', 'wpla') . '</a></p>'; $msg .= '<div id="wpla_dupe_details" style="display:none"><p>'; $msg .= __('To list on Amazon it is important for each product to have a unique SKU.', 'wpla'); $msg .= ' '; $msg .= __('Additionally, there can be only one listing per product per account.', 'wpla'); $msg .= '<br>'; $msg .= '<br>'; $msg .= __('Please keep only one listing and remove all other duplicates from the database.', 'wpla'); $msg .= '<br><br>'; $msg .= $this->renderDupeTable($duplicateSKUs, 'sku'); // $msg .= $this->renderDupeTable( $duplicateASINs, 'asin' ); $msg .= $this->renderDupeTable($duplicateProducts, 'post_id'); // $msg .= __('If you are not planning to use the synchronize sales option, you can hide this warning in settings.','wpla'); $msg .= '</p></div>'; $this->showMessage($msg, 2); } }