Creating an Array Attribute Type

Permalink
After not discovering an already existing solution, my goal is to write a User Reviews attribute for the Product object in the eCommerce plugin. Each review will have:
user id associated,
product associated,
timestamp,
review (text area).


Then, similar to how i can choose various product attributes to appear on a page like price and description, I will be able to choose the "reviews" attribute to display user reviews for a product.

I have read this article on creating custom attributes:
http://www.concrete5.org/documentation/how-tos/developers/create-a-...

I am trying to do everything the concrete5 way and not just hack up the database. My problem is my new Attribute type is not directly analogous to the existing types, because the existing attribute types relate to product attributes in a 1-1 sort of way, where as my "Reviews" type will have many "review" objects per each product "Reviews" attribute.

I need a custom Attribute Type of "Reviews", which is essentially going to be an array (of "Review" objects).


Certainly someone has already developed this... the problem applies not just to customer reviews, but any attribute where you have a collection of values. I welcome any information on how to develop this the concrete5 way, or links to where this has already been done.

 
Mnkras replied on at Permalink Reply
Mnkras
thats probbably not how you should do it, personally, that would be a real pain to even attempt, just make a block,
coppaj replied on at Permalink Reply
But how would I do it with just a block? the reviews have to maintain their association with products.
tbcrowe replied on at Permalink Reply
tbcrowe
Conceptually, it does make sense to have a review attribute. Mnkras is right, though, that it's going to be a pain to implement. If you do want to do this, I would suggest looking at the select attribute type. It supports multiple options per attribute/product. Each option is it's own object in the database. That would be closest existing analogy that I know of.
coppaj replied on at Permalink Reply
I suspect the whole thing could be solved with clever use of the db.xml file for the new attribute type, but i'm not grasping it yet.
Ricalsin replied on at Permalink Reply
Ricalsin
tbcrow's answer doesn't make sense to me.
And I can't see it being implemented as a block either - for the same reason you mention.

That said, you could create an addon that would replace the product block for c5's core commerce system.

I would not try to install a new attribute as that will make C5's engine want to assign a new akID for it, therefore keeping your association to the actual product difficult. I would "use" the same (existing) ecommerce product key to save a value into another custom table that would hold the reviews. On the block's "view" I would then pull all the akID's out of that table, loop through and display them below a form textarea input field for a user to add another review. Not entirely easy, but doable and perhaps that will give you enough grasp to do it.

I'll pay for it when you're done. :) So too would others, I bet.
RadiantWeb replied on at Permalink Reply
RadiantWeb
I'm actually developing this for a project right now. if you hold tight I should have something within the week.

ChadStrat
RadiantWeb replied on at Permalink Reply
RadiantWeb
I should correct my statement, I'm only doing rattings...without comments. but it could easily be extended once I am done with it.

As a side note, I'm simply extending the existing ratings attribute type with a separate table for ratings. And then there will be a helper included to affiliate with pages,files,users, or ecom.

C