Claudia M Posted April 30, 2018 Share Posted April 30, 2018 Is there any way in admin/Product to have an "Add manufacturer" feature in the dropdown menu where you add the manufacturer instead of having to go to the manufacturer menu section each time you add a product? Thanks in advance, Claudia Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 30, 2018 Share Posted April 30, 2018 This seems simple enough. Be back soon. Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 30, 2018 Share Posted April 30, 2018 (edited) Please make these edits. In the admin /sources/products.index.inc.php: Near line 70, find: if (!empty($_POST['product_id']) && is_numeric($_POST['product_id'])) { On a new blank line ABOVE that, add: if (isset($record['manufacturer']) && $record['manufacturer'] == "new" && isset($record['newmanufacturer']['name'])) { if(($existing_manufacturer = $GLOBALS['db']->select('CubeCart_manufacturers', array('id'), array('name' => $record['newmanufacturer']['name']))) === false) { if (($record['manufacturer'] = $GLOBALS['db']->insert('CubeCart_manufacturers', $record['newmanufacturer'])) !== false) { $GLOBALS['main']->setACPNotify($lang['catalogue']['notify_manufacturer_create']); } else { $GLOBALS['main']->setACPWarning($lang['catalogue']['error_manufacturer_create'].' - no insert'); } } else { $record['manufacturer'] = $existing_manufacturer[0]['id']; $GLOBALS['main']->setACPWarning($lang['catalogue']['error_manufacturer_create'].' - name'); } } In the admin template products.inc.php: Near line 152, find: <option value="">{$LANG.form.none}</option> On a new blank line AFTER that, add: <option value="new">-- {$LANG.catalogue.title_manufacturer_add} --</option> Just a few lines further, find: </select> Change to: </select> If select '{$LANG.catalogue.title_manufacturer_add}', enter data below. About 20 lines further, find: <fieldset> <legend>{$LANG.catalogue.title_stock_control}</legend> On a new blank line ABOVE that, add: <fieldset><legend>{$LANG.catalogue.title_manufacturer_add}</legend> <div><label for="manu_name">{$LANG.catalogue.manufacturer}</label><span><input type="text" class="textbox required" id="manu_name" name="newmanufacturer[name]" value=""></span></div> <div><label for="manu_site">{$LANG.common.url}</label><span><input type="text" class="textbox" id="manu_site" name="newmanufacturer[URL]" value=""></span></div> </fieldset> Edited May 1, 2018 by bsmither Quote Link to comment Share on other sites More sharing options...
Claudia M Posted May 1, 2018 Author Share Posted May 1, 2018 Thank you so much Brian!! Quote Link to comment Share on other sites More sharing options...
Claudia M Posted May 1, 2018 Author Share Posted May 1, 2018 Trying to implement this today but my code isn't lining up with yours. I'm on CC 6.2.0 Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 1, 2018 Share Posted May 1, 2018 What is there according to the directions above? Quote Link to comment Share on other sites More sharing options...
Claudia M Posted May 1, 2018 Author Share Posted May 1, 2018 I got it to work. I copied the instructions from the email I received about the post, not the actual forum post. The email read and I couldn't find that complete line: Near line 70, find: if (!empty($_POST['product_id']) && is_numeric($_POST['product_id'])) { dbgClue('We are updating a product.',array(),false); FORUM READ: On a new blank line ABOVE that, add: Near line 70, find: if (!empty($_POST['product_id']) && is_numeric($_POST['product_id'])) { Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 1, 2018 Share Posted May 1, 2018 My bad. I just now edited my post above to remove the dbgClue() part of the statement. (I really have to start quadruple checking my postings.) Quote Link to comment Share on other sites More sharing options...
Claudia M Posted May 2, 2018 Author Share Posted May 2, 2018 There is one thing about this code. Not all my products have a manufacturer, but if I don't put anything in the field it won't let me save the other changes. The add manufacturer field you added just turns pinkish red. Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 2, 2018 Share Posted May 2, 2018 Doh! Didn't test for that. <fieldset><legend>{$LANG.catalogue.title_manufacturer_add}</legend> <div><label for="manu_name">{$LANG.catalogue.manufacturer}</label><span><input type="text" class="textbox" id="manu_name" name="newmanufacturer[name]" value=""></span></div> <div><label for="manu_site">{$LANG.common.url}</label><span><input type="text" class="textbox" id="manu_site" name="newmanufacturer[URL]" value=""></span></div> </fieldset> I removed the 'required' attribute from the text entry field. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.