Skip to content

Commit

Permalink
Fix bugs in seller product form.
Browse files Browse the repository at this point in the history
  • Loading branch information
openmvm committed Oct 13, 2022
1 parent 0cf7600 commit 307452a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
40 changes: 40 additions & 0 deletions main/marketplace/Models/Seller/Product_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,46 @@ public function addProduct($data = [])
$product_to_category_insert_builder->insert($product_to_category_insert_data);
}

// Product option
if (!empty($data['product_option'])) {
foreach ($data['product_option'] as $product_option) {
// Insert product option
$product_option_insert_builder = $this->db->table('product_option');

$product_option_insert_data = [
'product_id' => $product_id,
'option_id' => $product_option['option_id'],
'seller_id' => $this->customer->getSellerId(),
'customer_id' => $this->customer->getId(),
];

$product_option_insert_builder->insert($product_option_insert_data);

$product_option_id = $this->db->insertID();

// Insert product option value
if (!empty($product_option['option_value'])) {
foreach ($product_option['option_value'] as $option_value) {
// Insert product option value
$product_option_value_insert_builder = $this->db->table('product_option_value');

$product_option_value_insert_data = [
'product_option_id' => $product_option_id,
'product_id' => $product_id,
'option_id' => $product_option['option_id'],
'option_value_id' => $option_value,
'seller_id' => $this->customer->getSellerId(),
'customer_id' => $this->customer->getId(),
];

$product_option_value_insert_builder->insert($product_option_value_insert_data);

$product_option_value_id = $this->db->insertID();
}
}
}
}

// Product variants
if (!empty($data['product_variant'])) {
foreach ($data['product_variant'] as $product_variant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
<div class="col-sm-6">
<select name="product_variant[<?php echo $key; ?>][weight_class_id]" class="form-select">
<?php foreach ($weight_classes as $weight_class) { ?>
<option value="<?php echo $weight_class['weight_class_id']; ?>"><?php echo $weight_class['title']; ?></option>
<?php if ($weight_class['weight_class_id'] == $value['weight_class_id']) { ?>
<option value="<?php echo $weight_class['weight_class_id']; ?>" selected><?php echo $weight_class['title']; ?></option>
<?php } else { ?>
<option value="<?php echo $weight_class['weight_class_id']; ?>"><?php echo $weight_class['title']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
Expand Down

0 comments on commit 307452a

Please sign in to comment.