public function execute() { $app_settings_model = new waAppSettingsModel(); $settings = $app_settings_model->get(shopPricePlugin::$plugin_id); $ccm = new waContactCategoryModel(); $categories = array(array('id' => 0, 'name' => 'Все покупатели')); foreach ($ccm->getAll() as $c) { if ($c['app_id'] == 'shop') { $categories[$c['id']] = $c; } } $price_model = new shopPricePluginModel(); $prices = $price_model->getAll(); $_prices = array(); foreach ($prices as $price) { $_prices[$price['domain_hash']][] = $price; } $domain_routes = wa()->getRouting()->getByApp('shop'); $domains_settings = shopPrice::getDomainsSettings(); $this->view->assign('prices', $_prices); $this->view->assign('domain_routes', $domain_routes); $this->view->assign('categories', $categories); $this->view->assign('settings', $settings); $this->view->assign('domain_settings', $domains_settings); }
public function execute() { $price_model = new shopPricePluginModel(); $id = waRequest::post('id', 0, waRequest::TYPE_INT); $after_id = waRequest::post('after_id', 0, waRequest::TYPE_INT); try { $price_model->move($id, $after_id); } catch (waException $e) { $this->setError($e->getMessage()); } }
public function execute() { try { if ($id = waRequest::post('id')) { $price_model = new shopPricePluginModel(); $price_model->deleteById($id); $sql = "ALTER TABLE `shop_product_skus` DROP `price_plugin_" . $price_model->escape($id) . "`"; $price_model->query($sql); } } catch (Exception $e) { $this->setError($e->getMessage()); } }
public function execute() { try { $price_model = new shopPricePluginModel(); $price = waRequest::post('price', array()); if (!empty($price['id'])) { $price_model->updateById($price['id'], $price); } else { $id = $price_model->insert($price); $price['id'] = $id; $sql = "ALTER TABLE `shop_product_skus` ADD `price_plugin_{$id}` DECIMAL( 15, 4 ) NOT NULL"; $price_model->query($sql); } $this->response['price'] = $price_model->getById($price['id']); } catch (Exception $e) { $this->setError($e->getMessage()); } }
public function productCustomFields() { if ($this->getSettings('status')) { $domains = $this->getDomains(); $price_model = new shopPricePluginModel(); $prices = $price_model->getAll(); $sku_fields = array(); foreach ($prices as $price) { $field = 'price_plugin_' . $price['id']; $field_name = $price['name'] . " (" . $domains[$price['domain_hash']] . ")"; $sku_fields[$field] = $field_name; } return array('sku' => $sku_fields); } }
<?php $price_model = new shopPricePluginModel(); $prices = $price_model->getAll(); try { foreach ($prices as $price) { $sql = "ALTER TABLE `shop_product_skus` DROP `price_plugin_" . $price_model->escape($price['id']) . "`"; $price_model->query($sql); $price_model->deleteById($price['id']); } } catch (waDbException $e) { }