SAP Hybris - current selected category or product in storefront - sap

is possible get the currently selected product category or product in any mvc controller/service?
Thanks.

Yes, possible.
In ProductPageController.java, you will find ProductData as below.
final ProductData productData = productFacade.getProductForCodeAndOptions(productCode, extraOptions);
You will get Categories from,
productData.getCategories()
and similarly you will get product as well.

Related

Odoo How Can I update my value from another module's value

I have a question...
As you know in odoo we have sales and purchase apps. I am building a module which will be
provide update product prices in the sales module from the vendor price in the purchase app.
I created a wizard and linked to purchase app.
Okay here is my question...
I want to do this simply.
product.supplierinfo.["price"] = product.product_template["list_price"]
I tried:
for rec self.env["product.supplierinfo"]:
self.env[product.product_template["list_price"]] = rec.["price"]
But as you know it's not working ^^
Any advice for this?
i think you mean to do like this
new_price= self.env[product.product_template].write({
"list_price" : rec.price,
})

PrestaShop add to cart from custom module

I ma working on PrestaShop module, where the user can select some parameters on front view.
I need to add product to cart, including custom price, and selected parameters.
How should I do this? I don't want to override deafult behavior, as not all products will use my component.
Any help would be awesome.
Have a nice day, Bartek.
adding a product to a cart is pretty simple :
First create an empty cart :
$cart=new Cart();
... here you can set your cart properties id_address / id_carrier etc...
$cart->add();
Or, if you already have a cart to use just load the Cart object with its ID and perform :
$cart->updateQty($quantity, $id_product, $id_product_attribute, false);
$cart->update();
You should repeate the updateQty() method for each product / qties you'd need to add to the cart.
In order to customize product prices in cart you have to create product "specific prices" using the SpecificPrice object and bind them to that id_cart :
$mySpecificPrice = new SpecificPrice();
$mySpecificPrice->id_cart = $cart->id;
... add your discount / id_product here on specific price here ...
$mySpecificPrice->add();
Note that you can only set price discounts with SpecificPrice , surcharges are not allowed and will trigger an exeception.
If you need to increase your prices without any core modification, you'll forced to generate an Order and edit the order prices afterward.

Get customer orders in PrestaShop Web services

I just installed the PrestaShop API and it seems there is no way to find how to retrieve customer orders. I have the customers list, I have the orders list but I have nothing to link them.
http://localhost/api/orders?filter[id_customer]=[1]
there few other filters exists, more in docs
Work with v1.7.x:
$orders = Order::getCustomerOrders($id_customer);
If you also need get order details (like products), you can use this:
$order = new Order($id_order['id_order']);
$products = $order->getProducts();

Finding products by Tags (Prestashop)

I'm doing some modifications in the way that customers explore products in Prestashop 1.6. So, I'd like to know if is there a function that works similar to the getProducts() function but gets products from a defined tag (or tags)?
Thanks for your help.
I have looked to product class and I couldn`t find any similar function. You can get product tags, all tags, add tags, del and etc..
But you could write an additional functio, yes? In ps_product_tag table you have: id_product and id_tag so:
1) Find id_tag by product name from ps_tag table
2) Get all products ID from ps_product_tag table where product has assigned ID TAG
Thats it. And also you should do it by overiding Product class. Now you have an array with products id. So now you can use cycle and catch all infformation from products or whatever: $product = new Product($id_product);

Vb.net 2010 Reading sub properties of an object in reportViewer

I am creating some reports using object datasources.
I have the following scenario:
in my software the user can create a list of products specifying a code, the product name, the price and the vat rate (this last two attributes will be used as suggestions when the user will place the product inside an order).
When a user creates an order he can place products within it by specifying for each product the quantity and he can also override the suggested price and the vat rate.
So basically i have two models to represent the products:
ProductModel (used to define product name, product code and the default suggestion for price and vat rate)
OrderProductModel (used to place products within an order, specify the quantity and override the default product suggestion for price and vat number)
ProductModel:
id
code
name
price
vat
OrderProductModel:
id
order (reference to an OrderModel object)
product (reference to a ProductModel to read the code and the name and the suggestions for price and vat rate)
quantity
price
vat
Now what I need to do with my report is to fill a table of OrderProduct objects and show the following informations for each product:
code (orderProduct.product.code)
name (orderProduct.product.name)
price (orderProduct.price)
quantity (orderProduct.quantity)
(suppose orderProduct is an instance of OrderProductModel)
Now the question is "how to define the report rule to access to code and name?"...
I am using visual studio 2010 and by reading here: http://www.gotreportviewer.com/objectdatasources/index.html
they says that the syntax: =Fields!Object.Value.attribute no longer works...
I tought i could solve the problem by adding to the OrderProductModel some properties that will read the properties of the related ProductModel instance.
But i'm sure there are better way that does not break the model...
Just an update to this, its now fixed in SP1. The requirement to get it to work is to make sure ALL classes used in properties of the datasource are serializable.
more info at:
http://wraithnath.blogspot.com/2011/04/reportviewer-object-datasource-nested.html
I found that this is a bug...
if you make all your object serializable this should be fixed in the SP1 ...
read more here: http://blogs.msdn.com/b/brianhartman/archive/2010/10/27/nested-objects-in-local-mode.aspx