/** * Delete products. * * @return Mage_ImportExport_Model_Import_Entity_Product */ protected function _deleteProducts() { $idToDelete = null; while ($bunch = $this->_dataSourceModel->getNextBunch()) { $idToDelete = array(); foreach ($bunch as $rowNum => $rowData) { if ($this->validateRow($rowData, $rowNum) && self::SCOPE_DEFAULT == $this->getRowScope($rowData)) { $idToDelete[] = $this->_oldSku[$rowData[self::COL_SKU]]['entity_id']; } } } Mage::dispatchEvent('searchanise_import_delete_product_entity_after', array('idToDelete' => $idToDelete)); return parent::_deleteProducts(); }
protected function _deleteProducts() { parent::_deleteProducts(); // fix and clean up the debris of tables whith options $resource = Mage::getSingleton('core/resource'); $this->_connection->query("\n DELETE t1 FROM `{$resource->getTableName('catalog_product_option')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_entity')}` WHERE `entity_id` = t1.`product_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('catalog_product_option_title')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('catalog_product_option_price')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('catalog_product_option_type_value')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('catalog_product_option_type_title')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option_type_value')}` WHERE `option_type_id` = t1.`option_type_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('catalog_product_option_type_price')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option_type_value')}` WHERE `option_type_id` = t1.`option_type_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('custom_options_relation')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('custom_options_option_view_mode')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('custom_options_option_description')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('custom_options_option_default')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option')}` WHERE `option_id` = t1.`option_id`) = 0;\n DELETE t1 FROM `{$resource->getTableName('custom_options_option_type_image')}` AS t1 WHERE (SELECT COUNT(*) FROM `{$resource->getTableName('catalog_product_option_type_value')}` WHERE `option_type_id` = t1.`option_type_id`) = 0;\n "); return $this; }