SortOrder by dropPrice Prestashop 1.7 - prestashop

there are default sort orders in PS 1.7 like >
(new SortOrder('product', 'price', 'asc'))........
(new SortOrder('product', 'date_add', 'asc'))->setLabel( etc etc
but what I want to know is that is it possible to get SortOrder by Price drop? so that it will show product by asc or des DropPrice list, which should be like
(new SortOrder('product', 'dropPrice', 'asc'))
I want to filter it by "highest discounts & Lowest discount". so the page will show products with the highest amount of discount "asc or dsc" & vise versa.
Hope you all get my point.

It does not seem like a good idea.
Discounts usually depend on certain individuals, groups and categories.
With this method, you have to disable the PrestaShop cache feature or add very complex price display requirements to the system. Because the contents of the page must be reviewed and displayed for each user individually.

Related

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.

Prestashop Multistore - local product attributes cost overwritten by default shop

My question is related to already solved issue where saving product in "All shops" context made prices in all shops the same no matter the currency. So if product in Poland would cost for example 100 PLN, then in Germany 100 EUR and in Great Britain 100 GBP. Link to this topic:
Prestashop Multistore - local store prices are overwritten with price from default shop
Anyways the provided solution doesn't cover this very same problem of product combinations additional costs. So I want to ignore those fields when saving product in "All shops" context.
Does anyone know how to solve it??
I achieved it by editing overriden Product.php (from /classes/Product.php) - funtion updateAttribute (around line 1800+). I took it's body, except return, into an if statement:
public function updateAttribute(...) {
if (Shop::getContext() == Shop::CONTEXT_SHOP){
// function body here
}
return true;
}
Now when saving product with combinations in "All shops", it's not updating product attributes (additional price, stock etc.) - those can only be saved in context of specific/selected shop.

SAP Hybris - current selected category or product in storefront

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.

Bigcommerce API - Create Shipment - Include all Items

according to the documentation, the Create Shipment method requires the property "items" - an array of the items being shipped, for example:
{
"tracking_number": "EJ958083578US",
"comments": "Ready to go...",
"order_address_id": 1,
"items": [
{
"order_product_id": 15,
"quantity": 2
}
]
}
In our business, a shipment almost invariably contains ALL items from the relevant order.
That being the case, is there a way to create a shipment without listing all items (which would require iterating over the product line-items)? Or, alternatively, a way to include all items by default (without iterating)?
We are simply wishing to automate the process of adding tracking numbers to orders - which (as a manual process) involves uploading a csv with [order_number: tracking_number] - i.e. it self-evidently assumes that all items are being shipped. The API seems not to include that (very sensible) option, but I may be wrong.
From Bigcommerce Support:
There is not a way to add a tracking number without adding a shipment nor a way to default the shipment to include all products. This is a helpful suggestion though that I will be passing on to our Product Team for possible implementation into future versions of the API.
Unfortunately for now it is necessary that you GET to the products subresource of an order and iterate over all of the products to pull their 'id' values and 'order_address_id' values so you can generate your POST request to the shipment subresource. It is not necessary to make a GET request to the shipping address subresource directly unless you want the details of that shipping address. It is also not necessary to make a GET request to the base order object unless you want details found there or you are looking to automate the process of checking for orders ready to ship.
So assuming you know an order ID that you want to ship it should only take 2 requests total to both GET the products subresource and then POST to the shipment resource.

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