There is only one model in this project—shop_model.php
—which contains functions that are specific to searching and writing products to the database.
This is our one and only model for this project; let's briefly go over each function in it to give us a general idea of what it does, and then we will go into more detail in the code.
There are five main functions in this model, which are as follows:
get_product_details()
: This accepts one argument—the$product_id
—of the product being added to the cart and returns a database result object that contains information about a specific product. This model function is used by theshop
controller'sadd()
function to fetch the correct details about a product before it is added to the cart.get_all_products()
: This accepts no argument. This model function will return a list of products (as defined in theproducts
table) to theshop
controller'sindex()
function.get_all_products_by_category_name()
: This accepts one argument—$cat_url_name...