Author Topic: One customfield, several products in vm3  (Read 1721 times)

emedina

  • Jr. Member
  • **
  • Posts: 51
One customfield, several products in vm3
« on: January 24, 2017, 13:10:31 pm »
Hi everybody.

A small introduction. Imagine you have a t-shirt store. You need Size customfield, maybe color one. In your store you have 1000 products, so in your virtuemart_product_customfields table you have 6000 entries. That's a lot.

In virtuemart 2 I found a trick. I only asigned size and colour in one product. Then copy the customfields template html output and paste in the whole template. In helpers/cart.php i commented:
// $product -> customfieldsCart = empty($tmpProduct -> customfieldsCart)? array(): $tmpProduct -> customfieldsCart;
With this little hack, all products in cart had the size and colour customfields.

Now in vm3 is more dificult. In helpers/cart.php the function "add" check customfields with this line:
$product->customfields = $customFieldsModel->getCustomEmbeddedProductCustomFields($product->allIds,0,1);

Ok, i've developed a plugin that extends virtuemartCart and links a custom vmprices.js in the frontend. When i debug the cart, the products have "fake" customfields (ok, that's good), but are not showing in the cart, neither in orders because product customfields are checked more times with the function getCustomEmbeddedProductCustomFields.


Is there anyway to make this work again without hacking the core? Maybe a pluggin that modify the product in the cart and in the order?

Thanks a lot.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10213
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emedina

  • Jr. Member
  • **
  • Posts: 51
Re: One customfield, several products in vm3
« Reply #2 on: January 26, 2017, 17:39:22 pm »
That is a very good solution, but i've customers who are accustomed to create products without specifing product's parent.
I'm wondering what would happen if i create a product with all the customfields and then override all products in template like this $this->product->product_parent_id=$the_fake_one.

I think the template isn't the best place to do this. Maybe in a plugin, but, is there any list with all the plugins triggers?

P.S. GREAT job team!!

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10213
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: One customfield, several products in vm3
« Reply #3 on: January 27, 2017, 08:58:29 am »
I do not understand, why you cannot use the pattern, you should play a bit with it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/