| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Duplicating File Attachments module | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Duplicating File Attachments module
Client wants two extra tabs for each product. A file downloads area and a case studies area.
I'm 98% there. I've duplicated the file attachments module and re-coded as necessary to create new fields in the database and files in the file system. I have a problem though.. The code... Code:
Call to a member function getProduct() on a non-object in $path = parent::getStoreFileSystemRoot() . $this->getCasestudy()->getProduct()->getProductId() . LC_DS; If I hard code the path it works but the attachment_id field in the database isn't filled in and therefor the list of attachments doesn't work properly until I put in the missing value manually. Any ideas? I was wondering if the Monthly Support subscription would enable me to get little things like this sorted? I have one big project at the moment on x5 and often little questions.
__________________
Core version: 5.5.xx |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Duplicating File Attachments module
Could you please show us a full error message?
It says "Call to a member function getProduct() on a non-object", but I do not see what object getProduct() method is called upon? This code would help understand what is wrong.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#3
|
|||||||
|
|||||||
Re: Duplicating File Attachments module
Call to a member function getProduct() on a non-object in /home/client/public_html/xcart5_2/var/run/classes/XLite/Module/client/CaseStudies/Model/Product/Casestudy/Storage.php on line 95
line 95 is... $path = parent::getStoreFileSystemRoot() . $this->getCasestudy()->getProduct()->getProductId() . LC_DS;
__________________
Core version: 5.5.xx |
|||||||
#4
|
|||||||
|
|||||||
Re: Duplicating File Attachments module
Some more information that might help...
In the module (File Attachments) that I'm attempting to duplicate there's this code to upload a file... Code:
one of the changes in the module code I've made is to change the fileObject... Code:
Can you explain what this fileObject is a little and what the process is that uploading a file starts. I want to make sure I'm dealing with this correctly in my module.
__________________
Core version: 5.5.xx |
|||||||
#5
|
|||||||||
|
|||||||||
Re: Duplicating File Attachments module
@xgarb, generally speaking the problem is caused by the fact that the $this->getCasestudy()->getProduct() construction does not return a product object. You need to find out why and it will be a key to how to fix the problem.
If you grep by 'fileObject' substring through X-Cart code, you will see that it is used for definition of POST variable where we should look for the actual file uploaded.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#6
|
|||||||
|
|||||||
Re: Duplicating File Attachments module
In the following...
Code:
Am I right in thinking that the code creates a storage object and then adds the uploaded file to it? I can't find setAttachment anywhere in the x5 source code to see what it's doing.
__________________
Core version: 5.5.xx |
|||||||
#7
|
|||||||
|
|||||||
Re: Duplicating File Attachments module
Any pointers?
Thanks, Andrew
__________________
Core version: 5.5.xx |
|||||||
#8
|
|||||||||
|
|||||||||
Re: Duplicating File Attachments module
Yes, you are right. This code creates a storage object and then links storage and attachment objects.
If you grep by "on setAttachment(" substring in the source code, you will see that the method is defined in the following files: var/run/classes/XLite/Module/CDev/Egoods/Model/OrderItem/PrivateAttachment.php var/run/classes/XLite/Module/CDev/FileAttachments/Model/Product/Attachment/StorageAbstract.php Please let me know if my reply is any helpful, because I am not sure about that
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#9
|
|||||||
|
|||||||
Re: Duplicating File Attachments module
Thanks. I found it and the module now works.
I hadn't realised that X-cart 5 moves and creates methods in the run directory that don't exist in the normal xlite directory.
__________________
Core version: 5.5.xx |
|||||||
|
|||
X-Cart forums © 2001-2020
|