/** * Remove product * * @param string $passkey * @param string $intRowid * @return string */ public function remove_product($passkey, $intRowid) { if (!$this->check_passkey($passkey)) { return self::FAIL_AUTH; } $product = Product::Load($intRowid); if (!$product) { //_xls_log("SOAP ERROR : Product id does not exist $intRowid ."); //We were asked to delete a product that was apparently already deleted, so just ignore return self::OK; } try { $this->remove_product_images($passkey, $intRowid); $this->remove_product_qty_pricing($passkey, $intRowid); $this->remove_related_products($passkey, $intRowid); $gifts = GiftRegistryItems::LoadArrayByProductId($intRowid); foreach ($gifts as $gift) { $gift->Delete(); } $citems = CartItem::LoadArrayByProductId($intRowid); foreach ($citems as $item) { if ($item->Cart && in_array($item->Cart->Type, array(CartType::cart, CartType::giftregistry, CartType::quote, CartType::saved))) { $item->Delete(); } } $product->Delete(); } catch (Exception $e) { Yii::log("SOAP ERROR : Error deleting Product " . $product->code . " " . $e, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); return self::UNKNOWN_ERROR; } return self::OK; }