Validate zip code using just first 4 digits - magento

I'm using table rates to assign shipping costs in Magento.
Our zip codes are in the following format: XXXX-XXX. Is there any "easy" way I can change the validation so that 1234-234 is assigned the same shipping cost as 1234-678 without doing it explicitly?
I would like to fill the tablerates.csv file like this:
Country,Region/State,"Zip/Postal Code","Order Subtotal (and above)","Shipping Price"
US,*,1234,20,5
and the system would assign 5 as the shipping cost to 1234-234, since 1234 is contained within 1234-234.
I'm imagining a simple change from "if clientzip = csvzip" to "if clientzip like 'csvzip%" somewhere in Magento's files...

I found a workaround. My country didn't have regions set in the database, so I added the three relevant regions to my country (in terms of shipping costs).
INSERT INTO db_magento.directory_country_region (
region_id ,
country_id ,
code ,
default_name
)
VALUES (
NULL , 'CountryCode', 'RegionCode', 'Region Name')
Now the system automatically forces filling out the "State/Province" field.

Related

Column slicer in Power BI report?

I have a requirement to cook my report with local languages. I have three description columns in my table and need to show one at a time based on user input.
Example:
CustName | Product | English_Description | Swedish_Description
My table has 5 millions of records, so i can't go for un-pivot the description columns. if I do un-pivot, my table becomes 10 millions of records. it's not a feasible one.
Some sample data would be useful. However, you could do a disconnected (or parameter) table for the language selection:
Language
--------
English
Swedish
This table wouldn't be related to anything else, but you could then use measures for your product descriptions such as:
Multi-lingual Description =
IF (
'Disconnected Table'[Language] = "Swedish",
MAX ( [Swedish_Description] ),
MAX ( [English_Description] )
)
With this logic, if no language is picked, the English description will be used. You could use different behavior too (for example use HASONEVALUE to ensure a single value is selected, and display an error message if not).
MAX in the measure is because a measure has to aggregate; however, as long as your table has one product for each row, then the MAX of the product name will be the product name you expect. Having more than one product per row doesn't make sense, so this should be an acceptable limitation. Again, to make your measure more robust, you could build in logic using HASONEVALUE to show BLANK() or an error message if there is more than one product (e.g. for subtotals).
More information:
HASONEVALUE: https://msdn.microsoft.com/en-us/library/gg492190.aspx
Disconnected Tables: http://www.daxpatterns.com/parameter-table/

SSRS Tablix Cell Calculation based on RowGroup Value

I have looked through several of the posts on SSRS tablix expressions and I can't find the answer to my particular issue.
I have a dashboard I am creating that contains summary data for various managers. They are entering monthly summary data into a single table structured like this:
Create TABLE OperationMetrics
AS
Date date
Plant char(10)
Sales float
ReturnedProduct float
The data could use some grouping so I created a table for referencing which report group these metrics go into looks like this:
Create Table OperationsReport
as
ReportType varchar(50)
MetricType varchar(50)
In this table, 'Sales' and 'ReturnedProduct' are the Metric column, while 'ExecSummary' or 'Quality' are ReportType entries. To do the join, I decided to UNPIVOT the OperationMetrics table...
Select Date, Plant, Metric, MetricType
From (Select Date, Plant, Sales, ReturnedProduct From OperationMetrics)
UNPVIOT (Metric for MetricType in (Sales, ReturnedProduct) UnPvt
and join it to the OperationsReport table so I have grouped metrics.
Select Date, Plant, Metric, Rpt.MetricReport, MetricType
FROM OpMetrics_Unpivoted OpEx
INNER JOIN OperationsReport Rpt on OpEx.MetricType = Rpt.MetricType
(I understand that elements of this is not ideal but sometimes we are not in control of our destiny.)
This does not include the whole of the tables but you get the gist. So, they have a form they fill in the OperationMetrics table. I chose SSRS to display the output.
I created a tablix with the following configuration (I can't post images due to my rep...)
Date is the only column group, grouped on 'MMM-yy'
Parent Row Group is the ReportType
Child Row Group is the MetricType
Now, my problem is that some of the metrics are calculations of other metrics. For instance, 'Returned Product (% of Sales)' is not entered by the manager because it is assumed we can simply calculate that. It would be ReturnedProduct divided by Sales.
I attempted to calculate this by using a lookup function, as below:
Switch(Fields!FriendlyName.Value="Sales",SUM(Fields!Metric.Value),
Fields!FriendlyName.Value="ReturnedProduct",SUM(Fields!Metric.Value),
Fields!FriendlyName.Value="ReturnedProductPercent",Lookup("ReturnedProduct",
Fields!FriendlyName.Value,Fields!Metric.Value,"MetricDataSet")/
Lookup("Sales",Fields!FriendlyName.Value,Fields!Metric.Value,
"MetricDataSet"))
This works great! For the first month... but since Lookup looks for the first match, it just posts the same value for the rest of the months after.
I attempted to use this but it got me back to where I was at the beginning since the dataset does not have the value.
Any help with this would be well received. I would like to keep the rowgroup hierarchy.
It sounds like the LookUp is working for you but you just need to include the date to find the right month. LookUp will return the first match which is why it's only working on the first month.
What you can try is concatenating the Metric Name and Date fields in the LookUp.
Lookup("Sales" & CSTR(Fields!DATE.Value), Fields!FriendlyName.Value & CSTR(Fields!DATE.Value), Fields!Metric.Value, "MetricDataSet")
Let me know if I misunderstood the issue.

Magmi Price Change for Magento

I am using UnderstandingE's version of Magmi.
I use Magmi to automatically import a CSV file from our supplier. The supplier's CSV has a column that says the price that we will pay to our supplier - "wholesale_price."
But that is not the price that we want to display on our site. So we want Magmi to create a column for "price." The value should be something like (wholesale_price * 130%). Is this something we can do with Magmi?
Of course there is
use value replacer plugin , advanced syntax , there is a sample that calculates price for cost column.
Of course, you can use any column , so in your case:
for attribute to replace , enter : price <= this is the value you want to set
the formula to use would be:
{{ {item.wholesale_price}*1.30 }}
above is a formula for calculating the price according to your need.

Joining grouped tables

I have two different scripted data sets that I am pulling data from and aggregating (on the same key). What I want to do is to display one one line the aggregated data from both sources. The data is coming from a scripted data source (POJOs).
A simplified example is given below in which an Order has many Components, with each component being for a different customer at a different quoted price. Then when each Order is filled in different lots (or Fills) at different prices. I want to be able to produce a summary of each Order with the total Ordered and Filled quantity, and the weighted average quoted price and filled price.
An Order Component table
Order ID, Customer Num, Qty, Quoted Px
Ord01,Cust01,3,100
Ord01,Cust02,3,102
Ord02,Cust01,5,200
Ord02,Cust03,5,204
And then a Order Fullfillment table
OrderID,FillId,Qty,CostPx
Ord01,F01,4,100
Ord01,F02,2,106
Ord02,F03,2,200
Ord02,F04,8,210'
I would like to display something like this:
Order ID, Order Qty, Fill Qty, Avg Order Px, Avg Fill Px
Ord01, 6, 6, 101, 102
Ord02, 10, 10, 202, 208
I've tried using subreports and that seems to be able to get me the results but in a terrible format. The subtable headers repeat so every order gets it's own headers.
You may want to create a BIRT joined dataset between your two scripted datasets, based on a full outer join on the "order ID" column, and then use this joined dataset in your report. It should meet your needs.
I solved my problem by more or less following the following guide.
So I created a List linked to my first data source. I then added a group on Order ID so that I had one list row per Order. In the group header I added a 2x1 grid, I placed a table of the Order Components into one side of the grid and a table of Fills into the other. I had to add filters to both of these so that they only contained data for the correct OrderId. I then grouped the tables by OrderId, added my aggregation fields.
All that is left is to set the visibilty. So I set the visibility of the table details to false. In order to only show the table header once (instead of once per order) I added a Running Count aggregation to the List and set the visibiity to invisible when this aggregation was greater than 1.
Was actually quite easy in the end but took me ages to work out how to do it.

Magmi multi-store import

first of all, thank you for providing Magmi, it really helps us keeping our products up to date on daily basis.
I would like to ask you one question - We want to sell our products in Hungary and I want to ask you, how should we configure .csv files in order to have product names in different language? So far we havent done anything particular, I just set up some store management settings, so our .hu version is reachable using url.
Additional info:
Magento Store management setting:
Website Name
Store Name
Store View Name
ourshop.hu
Hu
Magyar
ourshop.sk
Sk
Slovenčina
We fill up these attributes in mamgi csv files:
sku,
_attribute_set,
_type,
magmi:delete,
_product_websites,
status,
visibility,
name,
url_key,
description,
short_description,
enable_googlecheckout,
category_ids,
weight,
price,
special_price,
special_from_date,
tax_class_id,
manage_stock,
use_config_manage_stock,
VeÄľkost:drop_down:1,
size,
brand,
spinview,
labeldiscount,
thumbnail,
small_image,
image,
media_gallery,
media_gallery_reset
Thank you very much.
Have you looked at using the "store" column?
The documentation is not bad: http://sourceforge.net/apps/mediawiki/magmi/index.php?title=Magmi_Behaviour_-_store_column
The store column in magmi accepts store view codes , one or several.
And also an example:
store,sku,attribute1,attribute2
"admin","0001","value1","value2" <= sets default values for attributes attribute1 & attribute2 for sku 0001
"sv1","0001","value1","value2" <= sets values for attributes attribute1 & attribute2 for store view sv1 for sku 0001
"sv1,sv2","0002","value1","value2" <= sets values for attributes attribute1 & attribute2 for store view sv1 & sv2 for sku 0002
Is that what you were looking for?

Resources