1

I am trying to get the path of a Custom Option File. It is contained inside of the option_value index. It looks like this.

a:10:{s:4:"type";s:10:"image/jpeg";s:5:"title";s:25:"the-goose-will-attack.jpg";s:10:"quote_path";s:68:"/media/custom_options/quote/t/h/94b0992d58b4478d13a2376f645d3b7c.jpg";s:10:"order_path";s:68:"/media/custom_options/order/t/h/94b0992d58b4478d13a2376f645d3b7c.jpg";s:8:"fullpath";s:102:"/var/www/mageprodcory/mage-webroot/media/custom_options/quote/t/h/94b0992d58b4478d13a2376f645d3b7c.jpg";s:4:"size";s:5:"42421";s:5:"width";i:450;s:6:"height";i:600;s:10:"secret_key";s:20:"94b0992d58b4478d13a2";s:3:"url";a:2:{s:5:"route";s:35:"sales/download/downloadCustomOption";s:6:"params";a:2:{s:2:"id";s:3:"133";s:3:"key";s:20:"94b0992d58b4478d13a2";}}}

As I understand, this is suppose to be JSON that can be decoded, but it looks like something is wrong with it, some characters seem encoded incorrectly. I don't think ;s:25 and such is suppose to be there.

I've tried disabling magic quotes, but that's not the cause.

Any idea why the JSON is incorrect, or am I doing this wrong?

1 Answer 1

1

It is actually not a JSON. It is serialized. The unserialize function will work.

var_dump(unserialize('a:10:{s:4:"type";s:10:"image/jpeg";s:5:"title";s:25:"the-goose-will-attack.jpg";s:10:"quote_path";s:68:"/media/custom_options/quote/t/h/94b0992d58b4478d13a2376f645d3b7c.jpg";s:10:"order_path";s:68:"/media/custom_options/order/t/h/94b0992d58b4478d13a2376f645d3b7c.jpg";s:8:"fullpath";s:102:"/var/www/mageprodcory/mage-webroot/media/custom_options/quote/t/h/94b0992d58b4478d13a2376f645d3b7c.jpg";s:4:"size";s:5:"42421";s:5:"width";i:450;s:6:"height";i:600;s:10:"secret_key";s:20:"94b0992d58b4478d13a2";s:3:"url";a:2:{s:5:"route";s:35:"sales/download/downloadCustomOption";s:6:"params";a:2:{s:2:"id";s:3:"133";s:3:"key";s:20:"94b0992d58b4478d13a2";}}}'));

Credit goes to alexander.polomodov

https://stackoverflow.com/a/35870803/3774582

Your Answer

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.