Example #1
0
 /**
  * Delete a virtual product
  *
  * @param object $product
  */
 public function processDeleteVirtualProduct($product)
 {
     $id_product_download = \ProductDownloadCore::getIdFromIdProduct((int) $product->id, false);
     $download = new \ProductDownloadCore($id_product_download ? $id_product_download : null);
     if ($download) {
         $download->delete(true);
     }
 }
Example #2
0
 /**
  * Get virtual product data
  *
  * @return array
  */
 private function getVirtualProductData()
 {
     //force virtual product feature
     \ConfigurationCore::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', '1');
     $id_product_download = \ProductDownloadCore::getIdFromIdProduct((int) $this->product->id, false);
     if ($id_product_download) {
         $download = new \ProductDownloadCore($id_product_download);
         $dateValue = $download->date_expiration == '0000-00-00 00:00:00' ? '' : date('Y-m-d', strtotime($download->date_expiration));
         $res = ['is_virtual_file' => $download->active, 'name' => $download->display_filename, 'nb_downloadable' => $download->nb_downloadable, 'expiration_date' => $dateValue, 'nb_days' => $download->nb_days_accessible];
         if ($download->filename) {
             $res['filename'] = $download->filename;
             $res['file_download_link'] = $this->context->getAdminBaseUrl() . $download->getTextLink(true);
         }
         return $res;
     }
     return ['is_virtual_file' => 0, 'nb_days' => 0];
 }