Getting stock information in opencart 3.x - opencart

I want to implement a task similar to the one here Getting stock information in opencart 2.3.0.2, but my problem is that when deleting a product, the information about the warehouse will disappear. I want to enter the data into the table order_product, but I still don’t understand how. Help me please.
I can't figure out how to write information about the rest of the goods to the database. I don't understand how to implement it.

Hmm... You want to save product`s stock information in order_product table?
So first you must to add custom field in oc_order_product
ALTER TABLE `oc_order_product` ADD `stock_status` INT(11) NOT NULL AFTER `reward`;
Then in catalog/controller/checkout/confirm.php in $order_data['products'][] = array( You must add key - stock_status
'stock' => $this->model_catalog_product->getProduct($product['product_id'])['stock_status'],
So we modified our controller in customer side, and now our data receive the stock_status.
After receive products data from customer side, we must save in oc_order_table
Open path - catalog/model/checkout/order.php and edit addOrder function... After reward = '" . (int)$product['reward'] . "' in products loop add after comma:
stock_status = '" . $this->db->escape(product['stock_status']) . "'
I write an example, how to save data from customer side about product stock data.

Related

Default Power View for Power BI User

I am trying to build a page where it returns table for the logged in user. And then you can use the filter to look at other users records .
User = USERPRINCIPALNAME()
I am having problems filtering the table for the logged in user . Without using row level security with data model changes like below . Is there a way for the Power BI table to return data just for the logged in user ? No SSAS involved.
https://medium.com/#barrasa8/dynamic-data-masking-in-powerbi-based-on-rls-927eb6a34e5d**strong text**
The data model is a FACT table linked to a USER dimension. In the User Dimension , there is an email address which is what the USERPRINCIPALNAME() resolves to.
I thought about a DAX summary table with summarise and may try that later . Then 2 buttons on the page , one to show current logged in user and the other button just gives you details about all other users data and work with all the filters on the page .
So basic want is
Logged In User : X
Table - Col 1 , 2 ,3 .... ( Filtered for User x only by default )
Then I would like a way for the logged in user then to see others user data easily.
Unfortunately there is no way to use USERNAME() or USERPRINCIPALNAME() in DAX measures.
What you're left with is using row level security but that would mean it'll not be possible to show the data of other users.
The best alternative I can think of is to load the data twice. Then set Row Level Security on one table, display that one as "Your data", don't use RLS on the second table and display that as "Other people's data". Put them side by side for easy comparison.
I just wrote a blog post about a similar challenge on how to make sure you can still filter both tables: https://www.linkedin.com/pulse/calculating-totals-row-level-security-using-powerbi-van-der-pasch

How to fetch last inserted record for particular id?

Apologies, I am completely new to Django. My question is that I have 20 records in my database table and suppose 10 record is of same ID and I want to fetch last inserted record for that id I have date column in my table. How can I do that?
last_obj = YourModel.objects.last()
But generally, you can't create > 1 objects with same id, if you didn't specified your own id field to replace built-in. And even then, it's a bad idea.

OpenCart automatically add new products

I have to write code which will automatically add/delete/edit products on that opencart website, so my question is the following :
How to add new products to the database automatically with php?there are some methods in opencart, so I can use them, or I have to write the code from scratch
P.S: an example will be great (suppose we have the product information in an array)
Currently I am doing something similar to this, my setup is as follows:
Script: this is where the items are added, deleted or updated. I write directly into the database tables (product, product_description, product_to_store, category_id, product_to_category) by use of MySQL statements.
Since my sync happens concurrently, I have a CRON job triggering the script.
Logging: to keep track of whats happening I added a database table called log where I keep a record of what files are being processed, at what time, errors etc.
My conclusion is that you should create a model and controller which will handle this request to automatically add/delete/edit products and then whenever you need to run this you can just navigate to that script. Another clever thing to do would be to secure that script on the back-end so that only you are able to navigate to it.
An example of a MySQL insert statement for products as follows:
$insert_product = "INSERT INTO " . DB_PREFIX . "product ( sku, quantity, stock_status_id, status, date_added, price, taxpercentage, supplier, department, webshop, schedule)
VALUES ('".$sku."','" .$onhand. "','7','1',NOW(),'".$price. "','" .$tax_percentage. "','" .$supplier. "','" .$department. "','" . $webshop . "','" .$schedule. "')";

Formatting a portal in FileMaker 13 to show related text only and not keys

I am using FileMaker Pro 13. I need to add Portal to show data from related table.
Some fields which I wanna add to Portal are "Foreign keys" from that related table that are linked-related to third table.
Results I am getting in Portal from those fields are numbers, but I need data (text) from that third table that is related to that "Foreign key".
Is it possible to create portal that shows text related to that foreign key, and if it is, how to achieve that?
Thanks a lot!
Example schema is on link https://www.lucidchart.com/invitations/accept/e45dfdfd-185d-46c8-ad9e-e8e8dc270ee7
In general words, I want to add Portal on layout based on Table3, so I can view related data from Table2, and it would have fields tbl2item, TBL1_foreign key (from where I pull data from Table 1 when I enter data in Table 2, using pop up menu). And in Portal data I need TBL1_foreign key to be represented as text from related table instead of auto-numbers.
Assuming the relationship:
Table 1 --> Table 2 --> Table 3
You are in the layout based on Table 1. Make sure there is relationship to Table 3 and it is in the same group (TOG) in Manage Databases. Just place the field with text from the Table 3 on your portal row and it should work.
Make sure you select the correct relationship for Table 3. In drop-down list it should be in "Related" group. Should look like "Table 3::myFiled" on the layout, with the name the same as the name of your table instance (TO) from "Manage database" which could be different from your base table name
The other option would be to use value list.
I do not see your file, so if it does not work for you, post more details about your setup.

SQL Update table1.column1 if table1.column2 like table2.column2

I have two tables. Products P1 and Manufacturers M1. I want to see if the manufacturer_name is in the P1.title and update the P1.manufacturer_id with the M1.manufacturer_id.
UPDATE products P1
set P1.manufacturer_id=manufacturers.manufacturer_id
WHERE P1.title LIKE manufacturers.manufacturer_name;
I am getting Error "#1054 - Unknown column 'manufacturers.manufacturer_name' in 'where clause' "
Also, what is the correct syntax for WHERE P1.title LIKE %M1.manufacturer_name%?
Thank you.
You didn't post much about table structure, or the relationship between manufacturer and products, so the below is my best guess: please review and test it thoroughly. I'd prefer to write this using a JOIN, but without knowing what the foreign keys are, I'm not willing to take the chance on duplication ...
UPDATE P1
SET P1.Manufacturer_ID =
(
SELECT TOP 1 Manufacturer_ID
FROM Manufacturers
WHERE P1.Title LIKE '%' + manufacturer_name + '%'
)
FROM Products P1