-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
621 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/code/community/Ess/M2ePro/Model/Amazon/Account/DeleteManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
/* | ||
* @author M2E Pro Developers Team | ||
* @copyright M2E LTD | ||
* @license Commercial use is forbidden | ||
*/ | ||
|
||
class Ess_M2ePro_Model_Amazon_Account_DeleteManager | ||
{ | ||
/** @var Ess_M2ePro_Model_ActiveRecord_Factory */ | ||
protected $_activeRecordFactory; | ||
|
||
//######################################## | ||
|
||
public function __construct() | ||
{ | ||
$this->_activeRecordFactory = Mage::getSingleton('M2ePro/ActiveRecord_Factory'); | ||
} | ||
|
||
/** | ||
* @param \Ess_M2ePro_Model_Account $account | ||
* @return void | ||
* @throws \Ess_M2ePro_Model_Exception_Logic|\Ess_M2ePro_Model_Exception | ||
*/ | ||
public function process(Ess_M2ePro_Model_Account $account) | ||
{ | ||
$otherListings = $this->_activeRecordFactory->getObjectCollection('Listing_Other'); | ||
$otherListings->addFieldToFilter('account_id', $account->getId()); | ||
/** @var Ess_M2ePro_Model_Listing_Other $otherListing */ | ||
foreach ($otherListings->getItems() as $otherListing) { | ||
$otherListing->deleteProcessings(); | ||
$otherListing->deleteProcessingLocks(); | ||
|
||
$this->assertSuccess($otherListing->deleteInstance(), 'Listing Other'); | ||
} | ||
|
||
$listings = $this->_activeRecordFactory->getObjectCollection('Listing'); | ||
$listings->addFieldToFilter('account_id', $account->getId()); | ||
/** @var Ess_M2ePro_Model_Listing $listing */ | ||
foreach ($listings->getItems() as $listing) { | ||
$listing->deleteProcessings(); | ||
$listing->deleteProcessingLocks(); | ||
|
||
$listing->deleteListingProductsForce(); | ||
|
||
$this->assertSuccess($listing->deleteInstance(), 'Listing'); | ||
} | ||
|
||
$orders = $this->_activeRecordFactory->getObjectCollection('Order'); | ||
$orders->addFieldToFilter('account_id', $account->getId()); | ||
/** @var Ess_M2ePro_Model_Order $order */ | ||
foreach ($orders->getItems() as $order) { | ||
$order->deleteProcessings(); | ||
$order->deleteProcessingLocks(); | ||
|
||
$this->assertSuccess($order->deleteInstance(), 'Order'); | ||
} | ||
|
||
/** @var Ess_M2ePro_Model_Amazon_Account $amazonAccount */ | ||
$amazonAccount = $account->getChildObject(); | ||
|
||
$amazonAccount->deleteInventorySku(); | ||
$amazonAccount->deleteProcessingListSku(); | ||
|
||
$itemCollection = $this->_activeRecordFactory->getObjectCollection('Amazon_Item'); | ||
$itemCollection->addFieldToFilter('account_id', $amazonAccount->getId()); | ||
/** @var Ess_M2ePro_Model_Amazon_Item $item */ | ||
foreach ($itemCollection->getItems() as $item) { | ||
$item->deleteProcessings(); | ||
$item->deleteProcessingLocks(); | ||
|
||
$this->assertSuccess($item->deleteInstance(), 'Item'); | ||
} | ||
|
||
if ($amazonAccount->isRepricing()) { | ||
$amazonAccountRepricing = $amazonAccount->getRepricing(); | ||
|
||
$amazonAccountRepricing->deleteProcessings(); | ||
$amazonAccountRepricing->deleteProcessingLocks(); | ||
|
||
$this->assertSuccess($amazonAccountRepricing->$amazonAccountRepricing(), 'Account Repricing'); | ||
} | ||
|
||
Mage::helper('M2ePro/Data_Cache_Permanent')->removeTagValues('account'); | ||
|
||
$account->deleteProcessings(); | ||
$account->deleteProcessingLocks(); | ||
|
||
$this->assertSuccess($account->deleteInstance(), 'Account'); | ||
} | ||
|
||
/** | ||
* @throws \Ess_M2ePro_Model_Exception | ||
*/ | ||
private function assertSuccess($value, $label) | ||
{ | ||
if ($value === false) { | ||
throw new Ess_M2ePro_Model_Exception('Unable to delete ' . $label); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.