$product = new Product(); $product->setTitle('Example Product'); $product->setDescription('This is an example product'); $product->setPrice(19.99); $product->setCategory('Clothing'); $product->save(); // Save the product to the database
$product = Product::find(1); // Retrieve a product by ID echo 'This example shows how to retrieve and display a product using the PHP Product library. The `Product` class's `find()` method is used to retrieve a product by its ID. The various properties of the product such as title, description and price are then displayed on the page. Package/Library: PHP Product Library' . $product->getTitle() . '
'; echo '' . $product->getDescription() . '
'; echo 'Price: $' . $product->getPrice() . '
';