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. |
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. |
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; |
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:
<div class="add-file"> one of the changes in the module code I've made is to change the fileObject... Code:
<div class="add-file"> 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. |
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. |
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. |
Re: Duplicating File Attachments module
Any pointers?
Thanks, Andrew |
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 :) |
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. |
All times are GMT -8. The time now is 01:15 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.