1

I'm using the Squarebit Shortlist module and extending it to add multiple items at once using my own module. I'm calling shortlist_item_model->add and passing a key array with an entry_id and a list_id but for each time I call that function (despite passing the same list_id) the Shortlist module is creating a new list. I'm at a loss...

function Add_multiples() {

    ee()->load->add_package_path(PATH_THIRD.'shortlist');
    if(!class_exists('Shortlist_model')) ee()->load->library('Shortlist_model');
    if(!isset(ee()->shortlist_core_model)) Shortlist_model::load_models();

    // Before we do anything clear all lists
    ee()->shortlist_list_model->clear_list(array('all_lists'=>TRUE));

    $entry_ids = ee()->input->post('entry_ids');

    $keys = array();

    foreach($entry_ids AS $entry_id) {

        // Create our keys
        $keys['entry_id'] = $entry_id;

        // Insert our item into the default list
        $item_id = ee()->shortlist_item_model->add($keys);

        // Make sure we add subsequent items with the same list_id
        if (!isset($keys['list_id'])) {
            $item = ee()->shortlist_item_model->get_one($item_id);
            $keys['list_id'] = $item['list_id'];
        }
    }

}

Any thoughts greatly appreciated. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.