ragnabt Posted November 14, 2016 Share Posted November 14, 2016 Hi I really hope somebody can help. I´m trying to add the quantity field from the stock_available table to the stock management interface in the backend, so that it is possible to se both stock values. It´s should be as simple as the code below and i can writhe quantity in the fields_list, but then it shows the value from the product table. Then I add the sql but i cant seem to get the value from the stock table. Does anyone know how on earth i can do that? <?php class AdminStockManagementController extends AdminStockManagementControllerCore { public function __construct() { parent::__construct(); $this->_select .= 'crr.quantity as `stock_available`'; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'stock_available` crr ON (crr.`id_product` = p.`id_product`)'; $this->fields_list['stock_available'] = array( 'title' => $this->l('test felt 2'), 'orderby' => false, 'filter' => false, 'search' => false, 'class' => 'fixed-width-sm', 'align' => 'center', 'hint' => $this->l('rbt tstd'), ); } } Link to comment Share on other sites More sharing options...
ragnabt Posted November 15, 2016 Author Share Posted November 15, 2016 (edited) OMG! I figured it out myself... here is the code if someone is interested. file AdminStockManagementController.php location: override/controllers/admin remember to clear cache after uploading <?php class AdminStockManagementController extends AdminStockManagementControllerCore { public function __construct() { parent::__construct(); $this->fields_list['quantityonstock'] = array( 'title' => $this->l('Lager'), 'orderby' => false, 'filter' => false, 'search' => false, 'class' => 'fixed-width-sm', 'align' => 'center', 'hint' => $this->l('Disponibelt antal'), ); } public function renderList() { // sets actions $this->addRowAction('details'); $this->addRowAction('addstock'); $this->addRowAction('removestock'); if (count(Warehouse::getWarehouses()) > 1) $this->addRowAction('transferstock'); // no link on list rows $this->list_no_link = true; // inits toolbar $this->toolbar_btn = array(); // overrides query $this->_select = 'sta.quantity as quantityonstock, a.id_product as id, COUNT(pa.id_product_attribute) as variations'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)'.Shop::addSqlAssociation('product_attribute', 'pa', false); $this->_join .=' LEFT JOIN `'._DB_PREFIX_.'stock_available` sta ON (sta.id_product = a.id_product)'; $this->_where = 'AND a.is_virtual = 0'; $this->_group = 'GROUP BY a.id_product'; // displays informations $this->displayInformation($this->l('This interface allows you to manage product stock and their variations.').'<br />'); $this->displayInformation($this->l('Through this interface, you can increase and decrease product stock for an given warehouse.')); $this->displayInformation($this->l('Furthermore, you can move product quantities between warehouses, or within one warehouse.').'<br />'); $this->displayInformation($this->l('If you want to increase quantities of multiple products at once, you can use the "Supply orders" page under the "Stock" menu.').'<br />'); $this->displayInformation($this->l('Finally, you need to provide the quantity that you\'ll be adding: "Usable for sale" means that this quantity will be available in your shop(s), otherwise it will be considered reserved (i.e. for other purposes).')); return AdminController::renderList(); } } Edited November 15, 2016 by ragnabt (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now