Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/opencart/opencart/issues/11458
- Loading branch information
1 parent
83fbad8
commit 173cbbd
Showing
8 changed files
with
92 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace Opencart\Catalog\Model\Catalog; | ||
class SubscriptionPlan extends \Opencart\System\Engine\Model { | ||
public function getSubscriptionPlan(int $subscription_plan_id): array { | ||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "subscription_plan` sp LEFT JOIN `" . DB_PREFIX . "subscription_plan_description` spd ON (sp.`subscription_plan_id` = spd.`subscription_plan_id`) WHERE sp.`subscription_plan_id` = '" . (int)$subscription_plan_id . "' AND spd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'"); | ||
|
||
return $query->row; | ||
} | ||
|
||
public function getSubscriptionPlans(array $data = []): array { | ||
$sql = "SELECT * FROM `" . DB_PREFIX . "subscription_plan` sp LEFT JOIN `" . DB_PREFIX . "subscription_plan_description` spd ON (sp.`subscription_plan_id` = spd.`subscription_plan_id`) WHERE spd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'"; | ||
|
||
if (!empty($data['filter_name'])) { | ||
$sql .= " AND spd.`name` LIKE '" . $this->db->escape((string)$data['filter_name'] . '%') . "'"; | ||
} | ||
|
||
$sort_data = [ | ||
'spd.name', | ||
'sp.sort_order' | ||
]; | ||
|
||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { | ||
$sql .= " ORDER BY " . $data['sort']; | ||
} else { | ||
$sql .= " ORDER BY spd.`name`"; | ||
} | ||
|
||
if (isset($data['order']) && ($data['order'] == 'DESC')) { | ||
$sql .= " DESC"; | ||
} else { | ||
$sql .= " ASC"; | ||
} | ||
|
||
if (isset($data['start']) || isset($data['limit'])) { | ||
if ($data['start'] < 0) { | ||
$data['start'] = 0; | ||
} | ||
|
||
if ($data['limit'] < 1) { | ||
$data['limit'] = 20; | ||
} | ||
|
||
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; | ||
} | ||
|
||
$query = $this->db->query($sql); | ||
|
||
return $query->rows; | ||
} | ||
|
||
public function getTotalSubscriptionPlans(): int { | ||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "subscription_plan`"); | ||
|
||
return (int)$query->row['total']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters