Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product searching #22

Open
curtisdelicata opened this issue Sep 23, 2023 · 1 comment
Open

Product searching #22

curtisdelicata opened this issue Sep 23, 2023 · 1 comment
Assignees
Labels

Comments

@curtisdelicata
Copy link
Contributor

curtisdelicata commented Sep 23, 2023

Objective:
The current product search functionality in our eCommerce application needs enhancement to provide a better user experience and more accurate search results. The goal is to improve search performance, relevance, and user satisfaction.

Proposed Changes:

Use laravel scout

Enhanced Search Algorithm:
Update the search algorithm to improve relevance and accuracy of search results. Consider incorporating techniques like partial matching, synonym recognition, and prioritizing based on relevance.

Auto-Suggest and Auto-Complete:
Implement an auto-suggest and auto-complete feature to help users find products faster by suggesting relevant products or search terms as they type.

Filtering and Sorting:
Allow users to easily filter and sort search results based on relevant attributes such as price, category, availability, and customer ratings. Implement intuitive UI controls for this purpose.

Advanced Search Options:
Integrate advanced search options, allowing users to perform more refined searches based on specific criteria such as brand, size, color, and other attributes.

Search Result Preview:
Provide a preview of search results in real-time as the user types, giving them a glimpse of potential matches and encouraging them to refine their search further.

Acceptance Criteria:

The search functionality should display relevant products based on the user's input, considering partial matching and synonyms.
Auto-suggest and auto-complete should provide instant suggestions to aid users in finding products quickly.
Filtering and sorting options should be easily accessible and functional, enabling users to refine their search results effectively.
Advanced search options should allow users to specify detailed criteria for a more accurate search experience.
The search result preview should showcase relevant product snippets, encouraging users to explore further.
Additional Notes:
Consider conducting usability testing to gather feedback from users regarding the updated search functionality and make necessary adjustments based on the feedback received.

@curtisdelicata curtisdelicata transferred this issue from liberu-ecommerce/ecommerce-old Feb 28, 2024
Copy link
Contributor

sweep-ai bot commented Mar 11, 2024

Sweeping

✨ Track Sweep's progress on our progress dashboard!


25%

💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: ca5da54ef2)

Tip

I can email you when I complete this pull request if you set up your email here!


Actions (click)

  • ↻ Restart Sweep

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description.

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use HasFactory;
protected $table = 'products';
protected $fillable = [
'name',
'description',
'price',
'category',
'inventory_count',
];
public function categories()
{
return $this->belongsTo(ProductCategory::class);
}
public function cartItems()
{
return $this->hasMany(CartItem::class);
}
public function orderItems()
{
return $this->hasMany(OrderItem::class);
}
public function review()
{
return $this->hasMany(ProductReview::class);
}
public function rating()
{
return $this->hasMany(ProductRating::class);
}
}
public function downloadable()
{
return $this->hasMany(DownloadableProduct::class);

<?php
namespace App\Http\Controllers;
use App\Models\Product;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class ProductController extends Controller
{
public function create(Request $request)
{
// Handle Product File Upload
if ($request->hasFile('product_file')) {
$file = $request->file('product_file');
$filePath = $file->store('public/downloadable_products');
$fileUrl = Storage::url($filePath);
} else {
$fileUrl = null;
}
$validatedData = $request->validate([
'name' => 'required|string|max:255',
'description' => 'required|string',
'price' => 'required|numeric',
'category' => 'required|string|max:255',
'inventory_count' => 'required|integer',
// Include download limit in validation
'download_limit' => 'integer|nullable',
]);
$product = Product::create($validatedData);
// Create an initial inventory log entry
$product->inventoryLogs()->create([
'quantity_change' => $validatedData['inventory_count'],
'reason' => 'Initial stock setup',
]);
return response()->json($product, Response::HTTP_CREATED);
}
public function list()
{
$products = Product::all();
return response()->json($products);
}
public function show($id)
{
$product = Product::find($id);
if (!$product) {
return response()->json(['message' => 'Product not found'], Response::HTTP_NOT_FOUND);
}
return response()->json($product);
}
public function update(Request $request, $id)
{
$product = Product::find($id);
if (!$product) {
return response()->json(['message' => 'Product not found'], Response::HTTP_NOT_FOUND);
}
$validatedData = $request->validate([
'name' => 'string|max:255',
'description' => 'string',
'price' => 'numeric',
'category' => 'string|max:255',
'inventory_count' => 'integer',
]);
// Handle Product File Upload for Update
if ($request->hasFile('product_file')) {
$file = $request->file('product_file');
$filePath = $file->store('public/downloadable_products');
$fileUrl = Storage::url($filePath);
// Update Downloadable Product entry
$product->downloadable()->updateOrCreate(['product_id' => $product->id], ['file_url' => $fileUrl, 'download_limit' => $request->download_limit]);
}
$product->update($validatedData);
return response()->json($product);
}
public function delete($id)
{
$product = Product::find($id);
if (!$product) {
return response()->json(['message' => 'Product not found'], Response::HTTP_NOT_FOUND);
}
$product->delete();
return response()->json(['message' => 'Product deleted successfully']);
}
}
// Check if inventory_count is being updated and log the change
if (isset($validatedData['inventory_count'])) {
$quantityChange = $validatedData['inventory_count'] - $product->getOriginal('inventory_count');
$product->inventoryLogs()->create([
'quantity_change' => $quantityChange,
'reason' => 'Inventory adjustment',
]);

@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
@if($products->count() > 0)
@foreach($products as $product)
<div class="col-md-4 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">{{ $product->name }}</h5>
<p class="card-text">{{ $product->description }}</p>
<p class="text-muted">Price: ${{ number_format($product->price, 2) }}</p>
</div>
</div>
</div>
@endforeach
@else
<div class="col-12">
<p>No products available.</p>
</div>
@endif
</div>
<div class="row">
<div class="col-12 d-flex justify-content-center">
{{ $products->links() }}
</div>
</div>
</div>

@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ $product->name }}</div>
<div class="card-body">
<img src="/images/placeholder.png" alt="{{ $product->name }}" class="img-fluid mb-3">
<p><strong>Description:</strong> {{ $product->description }}</p>
<p><strong>Price:</strong> ${{ number_format($product->price, 2) }}</p>
<p><strong>Category:</strong> {{ $product->category }}</p>
<p><strong>Inventory Count:</strong> {{ $product->inventory_count }}</p>
</div>
</div>
<a href="{{ route('products.index') }}" class="btn btn-primary mt-3">Back to Products</a>
</div>
</div>
</div>
@endsection
@if($product->downloadable->count() > 0 && auth()->user() && auth()->user()->hasPurchased($product))
<a href="{{ route('download.generate-link', $product->id) }}" class="btn btn-success mt-3">Download</a>
@endif
<div class="card mt-4">
<div class="card-header">Inventory Logs</div>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Quantity Change</th>
<th>Reason</th>
</tr>
</thead>
<tbody>
@foreach ($product->inventoryLogs as $log)
<tr>
<td>{{ $log->created_at->format('Y-m-d H:i:s') }}</td>
<td>{{ $log->quantity_change }}</td>
<td>{{ $log->reason }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>


Step 2: ⌨️ Coding

Working on it...


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description.
Something wrong? Let us know.

This is an automated message generated by Sweep AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants