amsgames / laravel-shop

Laravel shop package
MIT License
483 stars 166 forks source link

Use "reference_id" colum (item table) to keep an array data #43

Open developez opened 8 years ago

developez commented 8 years ago

Hello

I am dealing with you great package, I want to propose to keep more data in the item table when you don't use a class. At this moment you can keep the sku, price and a id key of a certain class. But if you need to keep an array of ids for example (in my case, array of ids of two classes) you need to modifiy the table, I would to reuse the reference_id column that is null when you create a item without associated class, like this:

        $item_data = array();
        $item_data["myclass1"] = $oferta_tipo_id;
        $item_data["myclass2"] = $oferta_fecha_id;
        $item_data["sku"] = "...";
        $item_data["price"] = 100;
        $carro->add($item_data);

The idea is to retrieve this array when you read the items in the future:

foreach($items as $item)
    $item->getObjectAttribute

I can prepare a PR in this way if the owner wants.

amsgames commented 8 years ago

The item table is not a product table, that is why it doesn't hold more data in it.

This gives you freedom to create your own custom product tables with the properties of your needs. On Mar 23, 2016 3:20 AM, "Daniel López" notifications@github.com wrote:

Hello

I am dealing with you great package, I want to propose to keep more date in the item table. At the moment you can keep the sku, price and a id from a certain class. But if you need to keep an array of ids for example (in my case, array of ids of two classes) you need to modifiy the table, I would to reuse the reference_id column that is null when you create a item without class associate, like this:

    $item_data = array();
    $item_data["myclass1"] = $oferta_tipo_id;
    $item_data["myclass2"] = $oferta_fecha_id;
    $item_data["sku"] = "...";
    $item_data["price"] = 100;
    $carro->add($item_data);

The idea is to retreive this array when you read the items in the future:

foreach($items as $item) $item->getObjectAttribute

I can prepare a PR in this way if the owner wants.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43

developez commented 8 years ago

Yes, I understand. But with "class" and "reference_id" columns you can only store one id of a class. If you want to store two ids, you must create another class with these two ids in two properties or something, and save that class to a table.

I wonder how to get a good way to obtain a general method to store two o more id using "class" and "reference_id" columns. I want to avoid personalice the item tabs with more fields.

In my local fork (not yet uploaded) I did modification to achieve this, so probably it would'nt like everyone. I mean using reference_id to store an array of ids, by the moment encoding an array in json. The item table is not a product table, that is why it doesn't hold more data in it.

This gives you freedom to create your own custom product tables with the properties of your needs. On Mar 23, 2016 3:20 AM, "Daniel López" notifications@github.com wrote:

Hello

I am dealing with you great package, I want to propose to keep more date in the item table. At the moment you can keep the sku, price and a id from a certain class. But if you need to keep an array of ids for example (in my case, array of ids of two classes) you need to modifiy the table, I would to reuse the reference_id column that is null when you create a item without class associate, like this:

$item_data = array(); $item_data["myclass1"] = $oferta_tipo_id; $item_data["myclass2"] = $oferta_fecha_id; $item_data["sku"] = "..."; $item_data["price"] = 100; $carro->add($item_data);

The idea is to retreive this array when you read the items in the future:

foreach($items as $item) $item->getObjectAttribute

I can prepare a PR in this way if the owner wants.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43#issuecomment-201295628

amostajo commented 8 years ago

That approach sounds good. On Mar 25, 2016 9:53 AM, "Daniel López" notifications@github.com wrote:

Yes, I understand. But with "class" and "reference_id" columns you can only store one id of a class. If you want to store two ids, you must create another class with these two ids in two properties or something, and save that class to a table.

I wonder how to get a good way to obtain a general method to store two o more id using "class" and "reference_id" columns. I want to avoid personalice the item tabs with more fields.

In my local fork (not yet uploaded) I did modification to achieve this, so probably it would'nt like everyone. I mean using reference_id to store an array of ids, by the moment encoding an array in json. The item table is not a product table, that is why it doesn't hold more data in it.

This gives you freedom to create your own custom product tables with the properties of your needs. On Mar 23, 2016 3:20 AM, "Daniel López" notifications@github.com wrote:

Hello

I am dealing with you great package, I want to propose to keep more date in the item table. At the moment you can keep the sku, price and a id from a certain class. But if you need to keep an array of ids for example (in my case, array of ids of two classes) you need to modifiy the table, I would to reuse the reference_id column that is null when you create a item without class associate, like this:

$item_data = array(); $item_data["myclass1"] = $oferta_tipo_id; $item_data["myclass2"] = $oferta_fecha_id; $item_data["sku"] = "..."; $item_data["price"] = 100; $carro->add($item_data);

The idea is to retreive this array when you read the items in the future:

foreach($items as $item) $item->getObjectAttribute

I can prepare a PR in this way if the owner wants.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub <https://github.com/amsgames/laravel-shop/issues/43#issuecomment-201295628

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43#issuecomment-201341352

developez commented 8 years ago

I've seen some ways:

class = "Array" reference_id = "'class1_id' => 12, ...

class = "Array" or reference_id = "142, 767, ..."

class = "Class1, Class2, ..." reference_id = "12, 874, ..."

I need to this because I am selling products with two involved classes. El 25/3/2016 17:06, "Alejandro Mostajo" notifications@github.com escribió:

That approach sounds good. On Mar 25, 2016 9:53 AM, "Daniel López" notifications@github.com wrote:

Yes, I understand. But with "class" and "reference_id" columns you can only store one id of a class. If you want to store two ids, you must create another class with these two ids in two properties or something, and save that class to a table.

I wonder how to get a good way to obtain a general method to store two o more id using "class" and "reference_id" columns. I want to avoid personalice the item tabs with more fields.

In my local fork (not yet uploaded) I did modification to achieve this, so probably it would'nt like everyone. I mean using reference_id to store an array of ids, by the moment encoding an array in json. The item table is not a product table, that is why it doesn't hold more data in it.

This gives you freedom to create your own custom product tables with the properties of your needs. On Mar 23, 2016 3:20 AM, "Daniel López" notifications@github.com wrote:

Hello

I am dealing with you great package, I want to propose to keep more date in the item table. At the moment you can keep the sku, price and a id from a certain class. But if you need to keep an array of ids for example (in my case, array of ids of two classes) you need to modifiy the table, I would to reuse the reference_id column that is null when you create a item without class associate, like this:

$item_data = array(); $item_data["myclass1"] = $oferta_tipo_id; $item_data["myclass2"] = $oferta_fecha_id; $item_data["sku"] = "..."; $item_data["price"] = 100; $carro->add($item_data);

The idea is to retreive this array when you read the items in the future:

foreach($items as $item) $item->getObjectAttribute

I can prepare a PR in this way if the owner wants.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub < https://github.com/amsgames/laravel-shop/issues/43#issuecomment-201295628

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub < https://github.com/amsgames/laravel-shop/issues/43#issuecomment-201341352>

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/43#issuecomment-201345716