What is the easiest way to update value of attribute in Magento 2 on a daily basis? - magento2

I have three different delivery dates in my store and I want the user to choose from any of them (effects the price) on the (configurable) product page. I need these three to hold three different values:
4 days from now = "2017-09-04"
7 days from now = "2017-09-07"
10 days from now ="2017-09-10"
The Attribute 146 holds all three and presents the options to the customer in a dropdown menu. When the user makes his choice the product price changes.
My problem is that I dont want to update the values manually every day so I am looking for a way to automatize. First I tried to do it in configurable.phtml and change the value every time the page gets loaded. I am trying to use this line of code to be able to do it but I am having difficulties making it work.
<?php $this->action->updateAttributes([$product->getId()], ['deliverydate' > $newValue], $storeId); ?>
Now I am thinking of maybe I should set up a cron job to do it every night?
What do you think? Any suggestions?

Related

Google Sheets - Protect monthly range script needs monthly triggers at specified date and time

I would like to request help with a script Im trying to put together.
Linked is my test spreadsheet including the script I currently have on the second sheet.
The idea is that this sheet will be copied individually to a group of people. Each person will get their own sheet, editable only by them and myself. It does not get shared any further. Each day the person will add a value into the corresponding day's cell.
On the last day of each month at 8pm, I would like to protect (lock) the cells for that month, to stop the person changing any values that they previously entered.
I have put a repeating script together with a function for each month, covering each range. The problem I'm having is creating triggers that will run the function on the required day. If I set a monthly trigger, they will all trigger at the same time at the end of the first month. Ideally I need individual triggers that will run once a year on the specified date and time for each individual function.
Is this possible? Is there a better way of doing this?
I also realise that I will need to give permissions for each function run, and possibly for each individual copy of the sheet I give to said persons. Is there a clever way around that?
Im also thinking another approach would be for the script to trigger each monthly function 'on open' if the relative date has passed. For example, on Open, if Date is Feb 1st, lock January range, and so on.
Any help provided would be greatly appreciated.
(Note: the true sheet I copied my script and layout from starts this section at Column U, which is why I have minimised Columns A-T).
Test Sheet Link: https://docs.google.com/spreadsheets/d/13z8eWpo6oislkGX3USifLWqh5sz3DsJpSY1YyqNLrx8/edit?usp=sharing

MS Access: Make Form show only records from last 48HS

I am using MS Access and I have a table called tblLogs, it contains all the logs and a field called logDate. I have created a form in which I need to show the data from tblLogs, but only the records from the last two days. My question is: what are my options?
I've been doing some research and tried making a query which retrieves the data I need from last 2 days, but after doing it I realized there wasn't an easy way to bind query content to a Control (a text box in this case). Another option that came to mind was somehow setting an automatic filter that is triggered when you open the form (don't know how to do it yet), but I don't know if that would be convenient.
So, I'm all ears guys
In the form properties set Filter On Load to Yes and Filter to
logDate >= DateAdd('h', -48, Now())

How to filter two categories on dashboard? Tableau

I have 3 sheets I'd like to filter on the dashboard: months, supervisor name, and supervisee name. What I would like to do is have the functionality to click on a month, and have everything filter. I'd also like to click on the supervisor and supervisee, and have it do the same thing.
The problem is, that my supervisees keep disappearing every time I select a supervisor. The data is set up as a hierarchy within tableau and is on a corresponding line in the original hard data. Any help or suggestions?

Dynamic Number Of Inputs In Form

This is supposed to be something very common in access: Say you have a table Employees with a many-to-many relationship with a table Workdays. As in, A day of work is a record in Workdays, and for any day of work there can be multiple employees who worked that day (Which is shown with a third table, I think it's called a junction table?).
Now, say you want to create a form that the user inputs the employees who worked on a certain day. There is a changing number of employees per day, therefore a changing number of text boxes/combo boxes to input the employees in.
I want to ask if there's a conventional/convenient/acceptable way to do this. I've thought of 2 ways: Having a certain maximum number of text boxes invisible, and every time one receives input set the visible property on a new one to Visible=True, and second way by using the CreateControl method. Both ways seem a little pointlessly complicated for something that should be very common.
You don't have to mess with dynamically creating or showing/hiding individual controls. All you probably need is a main form for the Workday with a Subform Control for the Employees who worked that day, something like this:
Design View:
Form View:
The subform control contains a Continuous Forms form that is bound to the junction table [TimeCards].
Workday EmployeeID HoursWorked
--------- ---------- -----------
9/10/2014 1 7
9/10/2014 3 6
9/10/2014 4 9
The "child" subform linked to the "master" form by the [Workday] value. You can enter a variable number of entries for a given Workday by simply adding new rows to the subform (via the "New Record" row with the asterisk beside it).
For more information, see
Create a form that contains a subform

Access Crosstab or Form based on 2 tables with dates

There are a few answers here already that have part answered my challenge in Access but not fully.
I have 2 tables that form the basis of my database: customers and items
I have a further 2 tables; one for order quantities against customers and items (orders_a), and one for forecast quantities against customers and items (forecast_a).
forecast_a and orders_a also have a date for each customer and item combination (basically there will be 12 dates only for the 12 months of the year - 01/01/12,01/02/12,01/03/12 etc.)
Because a user will want to manually forecast quantities for a full year for each customer and each item, if there were 2 customers and 2 items, the forecast_a table would contain 48 rows. 2 items x 2 customers = 4, 4 x 12 dates = 48. The same goes for the orders_a.
I know this is a slightly unusual set up but the user requires visibility of a full year.
My main challenge based on this is as follows:
A user will want to see a form with customers in the first column, items in the second and then (like a crosstab): Jan Forecast Qty, Jan Order Qty, Feb Forecast Qty, Feb Order Qty etc.
Therefore how would I create a crosstab to pull both these tables together, and how would I go about creating a form for data entry off the back of it?
I may well be constructing my database the wrong way but the fact that the user needs a 'grid' where every entry is manual means I can't just have a form that creates a record one at a time for orders or forecasts.
Thanks in advance!
Nick
The problem you have is that this is a task that is in essence a spreadsheet task. Accordingly it may be best handled in Excel. To achieve this create an Excel object, create a blank worksheet, populate it with the data, then have a button to suck it back into the database when the user has finished.