set up product filter based on multiselection field in Pimcore - pimcore

Goal
I want to have a product filter based on a multiselection field of my data object.
Current setup
Project based on the official Pimcore Demo Application
Added a new data field to my data object class (type: Multiselection, name: selectionTest)
Manually update index via php bin/console ecommerce:indexservice:bootstrap --update-index
Create a new filter definition and add a FilterMultiSelectFromMultiSelect
Here I can select the field selectionTest, but the Pre Select field keeps empty (see screenshot)
select the filter definition in the product category
when I open now the product category in the shop frontend, I get following exception:
An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT TRIM(`selectionTest`) as `value`, count(*) as `count` FROM shop_productindex a WHERE active = 1 AND o_virtualProductActive = 1 AND inProductList = 1 AND o_type = 'variant' GROUP BY TRIM(`selectionTest`)':
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'selectionTest' in 'field list'").

Related

Hybris ImpEx - how to export all Orders, which contain a specific coupon code

I want to export all items of type Order, which contain a coupon code named 'TESTCOUPON'. However, when I try to do it, I get this error:
ERROR line 4 at main script: error executing code line at 4 : SQL search error - ORA-00932: inconsistent datatypes: expected - got BLOB
query = 'SELECT item_t0.PK FROM orders item_t0 WHERE ( item_t0.p_appliedcouponcodes = 'TESTCOUPON') AND (item_t0.TypePkString IN (?,?,?) )', values = [8796099149906, 8796099215442, 8796098756690]
I assume from the error that the coupon is stored in a Collection/List - how would I filter by it in this case?
The FlexibleSearch line looks like this:
SELECT {C:PK} FROM {Order as C} WHERE {C:appliedCouponCodes} = 'TESTCOUPON'
I tried using the PK of the coupon code, but it doesn't work either and it presents the same error. I tried using LIKE '%TESTCOUPON%' but then it said 'expected CHAR got BLOB'.
As per the Table structure CouponRedemption having reference of Order
.
so correct query will be as below.
select { o.code },{o.pk},{cr.couponCode} from {Order as o Join CouponRedemption as cr on {cr.order}={o.pk}} where {code}='TESTCOUPON'
Output:
code PK p_couponcode
1050156308 9499773075501 BUY4
1044303645 9499775172653 BUY4
1042057811 9499796897837 BUY4
1049853832 9499798863917 BUY4

one2many field stores only last record when fill

please help me regarding one2many field in odoo12.
firstly, sorry for bad grammar.
i am getting products from invoice_line_ids of account.invoice model.
but when i store these products in my custom model only last record is stored in one2many field in my class.
here is my code.
invoice_report = self.create(vals)
product_dict={}
product_list=[]
for line in ids.invoice_line_ids:
product_dict.update({
'product_name':line.product_id.name,
'qty':line.quantity,
'unit_price':line.price_unit,
'tax':line.invoice_line_tax_ids.name or "",
'subtotal':line.price_subtotal
})
product_list.append([(1,invoice_report.id,product_dict)])
for data in product_list:
invoice_report.write({
'inv_products':data
})
inv_products is my one2many field
invoice_report is my recently created record. i.e custom.invoice(1,)
According to the x2many values filling, the format you used updates an existing record of id id with the values in values. id should be an id of an inv_products record, not a custom.invoice record.
You should receive an Odoo server error in case record with id equal to 1 does not exist in the database:
One of the records you are trying to modify has already been deleted (Document type: custom.report.line).
(Records: (1,), User: 2)
You declared product_dict outside a for loop and you used update inside, at the end of the loop you will have the values of the last line of invoice_line_ids repeated, You asked the system to update a specific line (with id invoice_report.id) with the same values in each iteration when you called write method.
To add new records to inv_products, use [(0, 0, values)] format:
invoice_report = self.create(vals)
product_list = []
for line in ids.invoice_line_ids:
product_dict = {
}
product_list.append((0, 0, product_dict))
invoice_report.write({
'inv_products': product_list
})

Open XAVA How to Put Default value and Join column of another table

1 .For default value I have tried :
#Required
#Column(name="semester")
#DefaultValueCalculator(value=StringCalculator.class, properties=#PropertyValue(name="value", value="173"))
private String semester;
Getting error :
Error calculating default value
2 . Another Problem is I want to view column of another table into a table.
Table .
- Room [id, name]
- RoomAssigned [id , capacity , type ,status ]
In view/UI , I am showing RoomAssigned which has CRUD .
Now its showing column -
[id,capacity,type,status]
I want to add another column [name] from "Room" table . Here "Room" id is foreign key.
I want to get a view with view / UI :
[id,name,capacity,type,status]
I am new in OpenXava.Thanks in advance.
About the second point, you have to put the reference name in the #View members, use a #ReferenceView in the reference and create a #View in the referenced entity.
Read this documentation first:
http://openxava.wikispaces.com/view_en

Add an Item Group to Sales Order in Netsuite using SuiteTalk and PHP

I am trying to add Sales Orders with items of type "Item Group" using SuiteTalk via the PHP Toolkit.
When the item is of other types, e.g. "Inventory Item, Non-Inventory Item", the orders is added without problems.
When the item is of type "Item Group", I get the following error:
Code: INVALID_KEY_OR_REF
Message: Invalid price reference key 1 for
item NNNNNN. Type: ERROR
Where NNNNN is the internal ID of the child Inventory Item connected to this Item Group
Here is how I set my SalesOrderItem:
$nsItem = new SalesOrderItem();
$nsItem->item = new RecordRef();
$nsItem->item->internalId = $orderItem->product->foreignId;
$nsItem->item->type = $orderItem->product->itemType;
$nsItem->item->typeSpecified = true;
$nsItem->price = new RecordRef();
$nsItem->price->type = "priceLevel";
$nsItem->price->internalId = "-1"; // the default custom price level
$nsItem->rate = $orderItem->amounts->price;
$nsItem->quantity = $orderItem->qty;
Any thoughts?
UPDATE:
I made a workaround - I am checking each Sales Order Item for its type and if it is "Item Group" I am populating the Sales Order with the items from this group. It is a little bit slower but works.
If you run into this error, you'll notice that the item ID which is causing the error is not the same item specified on the header level of the invoice/sales order. The issue here is the "Base Price" (or whatever price level is internal ID 1) is not defined on that component item of the item group.
If you specify the "Base Price" this error will disappear!

Dynamics CRM Plugin - LINQ Query in 'Pre Validation'

I have a Dynamics CRM Plugin registered in "Pre Validation" and trigger on delete.
I have inside it a LINQ query that retrieve the maximum value of a date field of children records for a particular parent record.
Here is my code:
var q = (from e1 in serviceContext.CreateQuery<entity1>()
join e2 in serviceContext.CreateQuery<entity2>() on e1.typeid.Id equals e2.codeId
where e1.statecode == 0 && e1.ParentId.Id.Equals(new Guid(ParentGuidStr))
orderby e1.dt descending
select new {e1.dt, e2.code}).ToList();
I am getting the following error on the above query When the record that the plugin triggers on is INACTIVE:
PreValidateEntity1Delete PlugIn Error:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.ArgumentNullException:
Value cannot be null. Parameter name: g
I am NOT sure why I am getting the above error and if the link between an inactive children record and a parent record got broken in a LINQ query or there is another reason.
First, please ensure all children records have reference to parent record.
Then, change your where contidion into:
where e1.statecode == 0 && e1.ParentId != null && e1.ParentId.Id.Equals(new Guid(ParentGuidStr))
The problem is that an EntityReference field (e1.ParentId) may be null and when you tried access a null entity, the error appears.
Then because of that, you should also make sure e1.typeid is not null in the join condition too.
Or, you can try a workaround with 2 separate queries, and collect information from their results.
Good luck!

Resources