|
@@ -1,8 +1,6 @@
|
|
package modules
|
|
package modules
|
|
|
|
|
|
import (
|
|
import (
|
|
- "os"
|
|
|
|
-
|
|
|
|
"golang-fave/engine/wrapper"
|
|
"golang-fave/engine/wrapper"
|
|
"golang-fave/utils"
|
|
"golang-fave/utils"
|
|
)
|
|
)
|
|
@@ -36,35 +34,10 @@ func (this *Modules) RegisterAction_ShopDelete() *Action {
|
|
}
|
|
}
|
|
|
|
|
|
// Delete product attached images
|
|
// Delete product attached images
|
|
- rows, err := wrap.DB.Query(
|
|
|
|
- `SELECT
|
|
|
|
- product_id,
|
|
|
|
- filename
|
|
|
|
- FROM
|
|
|
|
- shop_product_images
|
|
|
|
- WHERE
|
|
|
|
- product_id = ?
|
|
|
|
- ;`,
|
|
|
|
- pf_id,
|
|
|
|
- )
|
|
|
|
- if err == nil {
|
|
|
|
- defer rows.Close()
|
|
|
|
- values := make([]string, 2)
|
|
|
|
- scan := make([]interface{}, len(values))
|
|
|
|
- for i := range values {
|
|
|
|
- scan[i] = &values[i]
|
|
|
|
- }
|
|
|
|
- for rows.Next() {
|
|
|
|
- err = rows.Scan(scan...)
|
|
|
|
- if err == nil {
|
|
|
|
- target_file_full := wrap.DHtdocs + string(os.PathSeparator) + "products" + string(os.PathSeparator) + "images" + string(os.PathSeparator) + string(values[0]) + string(os.PathSeparator) + string(values[1])
|
|
|
|
- os.Remove(target_file_full)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
if _, err := tx.Exec("DELETE FROM shop_product_images WHERE product_id = ?;", utils.StrToInt(pf_id)); err != nil {
|
|
if _, err := tx.Exec("DELETE FROM shop_product_images WHERE product_id = ?;", utils.StrToInt(pf_id)); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
+ wrap.RemoveProductImageThumbnails(pf_id, "*")
|
|
|
|
|
|
// Delete target product with category connection data
|
|
// Delete target product with category connection data
|
|
if _, err := tx.Exec("DELETE FROM shop_filter_product_values WHERE product_id = ?;", utils.StrToInt(pf_id)); err != nil {
|
|
if _, err := tx.Exec("DELETE FROM shop_filter_product_values WHERE product_id = ?;", utils.StrToInt(pf_id)); err != nil {
|