1

we are using an extension , so that the extension provides a text box in the admin panel.

if we enter the numbers in the admin panel text field means automatically it will save in the database table

we saved list of numbers in the database .

if the number is present in the database, than we have to display the message if condition

" available", if it is not present means than we have to display else condition "un avaialble"

please give me the php code for these kind of feature

please don't clsoe this question as un clear, if you have any doubts , please comment here, so that i will try to to clear it.....

asked Oct 5, 2015 at 13:38
4
  • 1
    Your question is too vague, could you please explain what is this "number" stored in the database ? Is that related to an object/model you created ? How did you store it in the first place ? Please elaborate Commented Oct 5, 2015 at 13:40
  • @DigitalPianism please check updated question Commented Oct 5, 2015 at 13:42
  • 1
    Thanks for the update, could you tell me if the admin field is a configuration field or if it's related to an entity (product, order, customer..). Please post a screenshot of the field if possible. Commented Oct 5, 2015 at 13:45
  • its an configuration field prntscr.com/8nzfna Commented Oct 5, 2015 at 13:47

1 Answer 1

1

If it's a configuration field, you need to find out what is the path of the field by looking at the system.xml file of the module.

You should find something like this:

<sections>
 <yourmodule translate="label" module="yourmodule">
 ...
 <groups>
 <group_tag translate="label">
 ... 
 <fields>
 <your_field translate="label">
 <label>Label of the field</label>
 ...
 </your_field>
 </fields> 
 </group_tag>
 </groups> 
 </yourmodule>
 </sections>

Thus, with the example above you can retrieve the value of the field using the following PHP code:

Mage::getStoreConfig('yourmodule/group_tag/your_field');

Edit: according to the system.xml file, here is how you can retrieve the values of your field:

Mage::getStoreConfig('checkdelivery/general/pincode');

However this field is comma separated so if you want an array you can just do:

$myArray = explode(',',Mage::getStoreConfig('checkdelivery/general/pincode'));

Then if you want to test if a number is in this array:

if (in_array($myNumber,$myArray))
{
// Number is present in the array
}
else
{
// Number is not in the array
}
answered Oct 5, 2015 at 13:57
7
  • this is the system.xml = pastebin.com/WgistWSJ Commented Oct 5, 2015 at 14:00
  • 1
    Is your field the Available ZIP code field ? Commented Oct 5, 2015 at 14:01
  • 1
    See my edit in my answer Commented Oct 5, 2015 at 14:06
  • 1
    Yes, it is. No need to call getStoreConfig again when setting the $myArray variable you can just do $myArray = explode(',',$myNumber); Actually my bad, $myNumber is supposed to be the number you want to check. I don't know exactly what is this number. Commented Oct 5, 2015 at 14:16
  • 1
    Let us continue this discussion in chat. Commented Oct 5, 2015 at 14:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.