What is the best way to save a list of SKU in the admin to use in frontend as an array?
-
16-01-2021 - |
Question
I need to create a list of SKU separated by commas (sku1,sku2) to use them in the frontend of the site as a global variable. I tried adding it as an attribute per product and I also tried to create a category then loading a collection in order to show the SKU on the page but it seems to be overkill considering I only need it for less than 10 products. I just need a textbox or textarea where the SKU can be stored and loaded in the frontend. Probably in the configuration catalog. Something like the System > Configuration > Advanced > Developer > Developer Client Restrictions text box. Since these need to be changed easily.
Solution
You can use System custom variables. You can set custom variables by navigating to 'System' > 'Custom Variables'
where you can set comma-separated text or HTML value also. You can access it in frontend with below code:
Mage::getModel('core/variable')->loadByCode('custom_variable_code')->getValue('text');