Ahmed wrote:Hello Mike,
Another Question, don't know if I should create a new topic for it ?
I want to export Jiwa Inventory Items from only a one Category to Magento. In my Jiwa Inventory there are more then 10k products which I don't need to export but are historical data.
Suppose I want to export Category -> Brand -> "ABC"
So how can I add Items to queue only with Brand name ABC ?
Please let me know if there is anyway to achieve that
Thanks
A new topic would have been good - as this was already marked as solved by yourself so I missed your question when looking for unsolved topics!
The candidates for export are determined by a trigger on the IN_Main table - so you can simply modify that trigger - below is the SQL script to re-create the trigger on IN_Main and only export items where the Category1 in Jiwa is 'XYZ':
- Code: Select all
IF EXISTS(SELECT * FROM sys.triggers WHERE Name = 'IN_Main_Magento_ChangedInventoryItemQueue')
DROP TRIGGER IN_Main_Magento_ChangedInventoryItemQueue
GO
CREATE TRIGGER IN_Main_Magento_ChangedInventoryItemQueue ON IN_Main AFTER INSERT, UPDATE, DELETE
AS
SET NOCOUNT ON
-- We only ever have one entry per product in the queue "Jiwa Inventory" - as this table is a queue
-- we do nothing if the item is already in the table, as when we process this queue we grab the oldest first
-- so this way we make sure no item gets neglected when there are high volumes
-- update any existing entries with a new LastChangedDateTime
UPDATE Magento_Queue
SET LastChangedDateTime = GETDATE()
FROM inserted i
WHERE Magento_Queue.Identifier = i.PartNo
AND Magento_Queue.QueueName = 'Jiwa Inventory'
AND Magento_Queue.Status = 0
-- Add the new entries
DECLARE @PartNos TABLE (
PartNo VARCHAR(50) NOT NULL
)
INSERT INTO @PartNos SELECT DISTINCT IN_Main.PartNo FROM inserted i
JOIN IN_Main ON IN_Main.InventoryID = i.InventoryID
JOIN IN_Category1 ON IN_Category1.Category1ID = IN_Main.Catagory1ID
WHERE IN_Category1.Description = 'XYZ'
INSERT INTO Magento_Queue(RecID, QueueName, Identifier, QueueInsertionDateTime, LastChangedDateTime, Status, ExceptionText)
SELECT NewID(), 'Jiwa Inventory', i.PartNo, GETDATE(), GETDATE(), 0, NULL
FROM @PartNos i
LEFT JOIN Magento_Queue ON Magento_Queue.Identifier = i.PartNo AND Magento_Queue.QueueName = 'Jiwa Inventory' AND Magento_Queue.Status <> 2
WHERE Magento_Queue.RecID IS NULL
GO
In the above trigger, all I added from the standard one is this:
- Code: Select all
JOIN IN_Category1 ON IN_Category1.Category1ID = IN_Main.Catagory1ID
WHERE IN_Category1.Description = 'XYZ'