本文整理汇总了PHP中ProductDownload::update方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductDownload::update方法的具体用法?PHP ProductDownload::update怎么用?PHP ProductDownload::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductDownload
的用法示例。
在下文中一共展示了ProductDownload::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateZip
/**
* generateZip
*
* @param AutoZipConfig $autozip
* @param string $version_number
*/
public static function generateZip(AutoZipConfig $autozip, $version_number = null)
{
// Move the configured folder as source folder
if ($autozip->source_folder) {
self::cliExec('mv download/' . $autozip->source_folder . ' source');
} else {
self::cliExec('mv download source');
}
// Zip with or without root folder in the zip
if ($autozip->zip_folder) {
self::cliExec('mv source ' . $autozip->zip_folder);
self::cliExec('zip -qr autozip.zip ' . $autozip->zip_folder);
} else {
self::cliExec('zip -qr ../autozip.zip . ', array(), _AUTOZIP_TMP_ . 'source');
}
if ($autozip->id_attachment) {
// get the Attachement config
$attachment = new Attachment($autozip->id_attachment);
if (!$attachment->file) {
throw new PrestaShopException('The Attachement does not exists. Please update the autozip association');
}
// Move the generated zip as the "regular" Attachement
self::cliExec('mv autozip.zip ' . _PS_DOWNLOAD_DIR_ . $attachment->file);
if ($autozip->zip_basename) {
$attachment->file_name = $autozip->zip_basename . ($version_number ? '-' . $version_number : '') . '.zip';
}
$attachment->mime = 'application/zip';
$attachment->update();
} else {
if ($autozip->id_product_download) {
// get the Product Download config
$product_download = new ProductDownload($autozip->id_product_download);
if (!$product_download->id_product) {
throw new PrestaShopException('The product Download does not exists. Please update the autozip association');
}
// Move the generated zip as the "regular" Product Download
self::cliExec('mv autozip.zip ' . _PS_DOWNLOAD_DIR_ . $product_download->filename);
if ($autozip->zip_basename) {
$product_download->display_filename = $autozip->zip_basename . ($version_number ? '-' . $version_number : '') . '.zip';
}
$product_download->date_add = date('Y-m-d H:i:s');
//Prestashop dos not like the way he is himself storing an empty date (we do not change this field)
if ($product_download->date_expiration === '0000-00-00 00:00:00') {
$product_download->date_expiration = null;
}
$product_download->update();
}
}
}