diff --git a/application/modules/backend/library/backend/commands/DeleteProductExtended.php b/application/modules/backend/library/backend/commands/DeleteProductExtended.php index e399342e4..0986acc19 100644 --- a/application/modules/backend/library/backend/commands/DeleteProductExtended.php +++ b/application/modules/backend/library/backend/commands/DeleteProductExtended.php @@ -1,135 +1,135 @@ . **/ class Backend_Commands_DeleteProductExtended implements Local_Queue_CommandInterface { /** @var Zend_Db_Table_Row_Abstract */ protected $product; /** * PHP 5 allows developers to declare constructor methods for classes. * Classes which have a constructor method call this method on each newly-created object, * so it is suitable for any initialization that the object may need before it is used. * * Note: Parent constructors are not called implicitly if the child class defines a constructor. * In order to run a parent constructor, a call to parent::__construct() within the child constructor is required. * * param [ mixed $args [, $... ]] * * @param Zend_Db_Table_Row_Abstract $product * * @link http://php.net/manual/en/language.oop5.decon.php */ public function __construct($product) { $this->product = $product; } public function doCommand() { $this->deleteProductFromIndex(); $this->deleteCollectionFromPPload(); $this->deleteImagesFromCdn(); } protected function deleteProductFromIndex() { if (empty($this->product->project_id) OR empty($this->product->project_category_id)) { Zend_Registry::get('logger')->warn(__METHOD__ . ' - no productId or catId was set.'); return; } $modelSearch = new Default_Model_Search_Lucene(); $modelSearch->deleteDocument($this->product->toArray()); } private function deleteCollectionFromPPload() { // ppload // Delete collection if ($this->product->ppload_collection_id) { $pploadApi = new Ppload_Api(array( 'apiUri' => PPLOAD_API_URI, 'clientId' => PPLOAD_CLIENT_ID, 'secret' => PPLOAD_SECRET )); $collectionResponse = $pploadApi->deleteCollection($this->product->ppload_collection_id); Zend_Registry::get('logger')->info(__METHOD__ . ' - product delete request for ppload: ' . $this->product->project_id . ' response: ' . print_r($collectionResponse, true)); } } private function deleteImagesFromCdn() { //Remove Logo $imgPath = $this->product->image_small; $newPath = $this->deleteImageFromCdn($imgPath); //save renamed images $this->product->image_small = $newPath; $projectTable = new Default_Model_DbTable_Project(); //$this->product->save(); $projectTable->update(array('image_small' => $newPath), "image_small = '".$imgPath."'"); //Remove Gallery Pics $galleryPictureTable = new Default_Model_DbTable_ProjectGalleryPicture(); $stmt = $galleryPictureTable->select()->where('project_id = ?', $this->product->project_id)->order(array('sequence')); foreach ($galleryPictureTable->fetchAll($stmt) as $pictureRow) { $imgPath = $pictureRow['picture_src']; $newPath = $this->deleteImageFromCdn($imgPath); //save renamed images //$galleryPictureTable->update(array('picture_src' => $newPath), 'project_id = '.$pictureRow['project_id'].' AND sequence = '.$pictureRow['sequence']); - $galleryPictureTable->update(array('picture_src' => $newPath), "picture_src = ".$imgPath."'"); + $galleryPictureTable->update(array('picture_src' => $newPath), "picture_src = '".$imgPath."'"); } } private function deleteImageFromCdn($imgPath) { $config = Zend_Registry::get('config'); $url = $config->images->media->delete; $secret = $config->images->media->privateKey; $postString = '--'.md5(rand()).md5(rand()); $url .= '?path='.urlencode($imgPath).'&post='.$postString.'&key='.$secret; $client = new Zend_Http_Client($url); $response = $client->request('POST'); if ($response->getStatus() > 200) { throw new Default_Model_Exception_Image('ERROR: Could not remove images from CD-Server: ' . $url . ' - server response: ' . $response->getBody()); } Zend_Registry::get('logger')->info(__METHOD__ . ' - Result fromCN-Server: ' . $response->getBody()); //save renamed images return $imgPath.$postString; } }