how to export only a single product to magento  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

how to export only a single product to magento

Postby jak » Sat Oct 15, 2016 4:43 pm

Hi!

we have multiple to products published in jiwa, but we only selected products to be published on website, as they are not ready for selling yet,
so how to export only selected products in magento using magento integration plugin in jiwa,

Thank you in Advance,
Akash
jak
Occasional Contributor
Occasional Contributor
 
Posts: 22
Joined: Mon Oct 10, 2016 10:00 pm
Topics Solved: 0

Re: how to export only a single product to magento  Topic is solved

Postby Mike.Sheen » Sun Nov 13, 2016 11:32 am

jak wrote:we have multiple to products published in jiwa, but we only selected products to be published on website, as they are not ready for selling yet,
so how to export only selected products in magento using magento integration plugin in jiwa,


Hi jak/Akash,

We queue products that have changed or have been created using an SQL Trigger - you could modify that to exclude items based on your criteria. Typically people want to exclude items where the "Web Enabled" flag is OFF.

The standard trigger looks like this:

Code: Select all
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

   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


If you change the line which reads

Code: Select all
INSERT INTO @PartNos SELECT DISTINCT IN_Main.PartNo FROM inserted i JOIN IN_Main ON IN_Main.InventoryID = i.InventoryID


To this:

Code: Select all
INSERT INTO @PartNos SELECT DISTINCT IN_Main.PartNo FROM inserted i JOIN IN_Main ON IN_Main.InventoryID = i.InventoryID WHERE IN_Main.WebEnabled = 1


Then items Web Enabled will no longer be queued.

An alternative to this is to not do the above, but use the Inventory Item status of the product instead. By default the Magento Integration plugin sets the store item's status (enabled or disabled) based on the inventory item status. In the CreateOrUpdateMagentoProductsFromJiwa method of the plugin, you'll find this piece of code:

Code: Select all
if (inventory.Status == JiwaFinancials.Jiwa.JiwaInventory.Inventory.InventoryStatuses.e_InventoryStatusActive || inventory.Status == JiwaFinancials.Jiwa.JiwaInventory.Inventory.InventoryStatuses.e_InventoryStatusSlow)
{
   productData.status = "1"; // 1 = Enabled
}
else
{
   productData.status = "0"; // 0 = disabled
}


You could also modify the above to make the product in the store disabled if WebEnabled was false also, so the product won't appear for shoppers, but it will be pushed up there, and when they do want to publish it, just turn on "Web Enabled" on the item in Jiwa.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 10 guests