X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Class not found (https://forum.x-cart.com/showthread.php?t=71686)

Phil Richman 03-24-2015 04:53 AM

Class not found
 
I'm working on a new module to add radio buttons as product option attributes. I created a class called Radio but xcart is not finding it. I keep getting the following error


[24-Mar-2015 09:43:41 America/Indiana/Indianapolis] PHP Fatal error: Class '\XLite\View\Product\AttributeValue\Admin\Radio' not found in /home/upflushi/www/var/run/classes/XLite/View/AViewAbstract.php on line 418
[24-Mar-2015 09:43:41] Error (code: 1): Class '\XLite\View\Product\AttributeValue\Admin\Radio' not found
Server API: apache2handler;
Request method: GET;
URI: /admin.php?target=product&product_id=1&page=attribu tes;
Backtrace:
#0 Includes\ErrorHandler::logInfo(Class '\XLite\View\Product\AttributeValue\Admin\Radio' not found, 1) called at [/home/upflushi/www/Includes/ErrorHandler.php:324]
#1 Includes\ErrorHandler::handleError(Array ([type] => 1,[message] => Class '\XLite\View\Product\AttributeValue\Admin\Radio' not found,[file] => /home/upflushi/www/var/run/classes/XLite/View/AViewAbstract.php,[line] => 418)) called at [/home/upflushi/www/Includes/ErrorHandler.php:309]
#2 Includes\ErrorHandler::shutdown()


The xlite.log contained



Mar 24 09:57:59 XLite [warning] Warning: include_once(/home/upflushi/www/var/run/classes/XLite/Model/AttributeValue/AttributeValueRadio.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home/upflushi/www/Includes/Autoloader.php on line 125
Server API: apache2handler;
Request method: GET;
URI: /admin.php?target=product&product_id=1&page=attribu tes;
Mar 24 09:57:59 XLite [warning] Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home/upflushi/www/var/run/classes/XLite/Model/AttributeValue/AttributeValueRadio.php' for inclusion (include_path='.:/usr/local/lib/php:/home/upflushi/www/lib/') in /home/upflushi/www/Includes/Autoloader.php on line 125
Server API: apache2handler;
Request method: GET;
URI: /admin.php?target=product&product_id=1&page=attribu tes;
Mar 24 09:57:59 XLite [warning] Warning: include_once(/home/upflushi/www/var/run/classes/XLite/View/Product/AttributeValue/Admin/Radio.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home/upflushi/www/Includes/Autoloader.php on line 125
Server API: apache2handler;
Request method: GET;
URI: /admin.php?target=product&product_id=1&page=attribu tes;
Mar 24 09:57:59 XLite [warning] Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home/upflushi/www/var/run/classes/XLite/View/Product/AttributeValue/Admin/Radio.php' for inclusion (include_path='.:/usr/local/lib/php:/home/upflushi/www/lib/') in /home/upflushi/www/Includes/Autoloader.php on line 125
Server API: apache2handler;
Request method: GET;
URI: /admin.php?target=product&product_id=1&page=attribu tes;




Any ideas?

qualiteam 03-24-2015 07:38 AM

Re: Class not found
 
Hello Phil,

How did you add the class?
Where is the file with the class definition located?
What is the source code?

totaltec 03-24-2015 07:56 AM

Re: Class not found
 
At the top of your radio.php, what is your namespace?

Phil Richman 03-24-2015 08:12 AM

Re: Class not found
 
It is located in:
/classes/XLite/Module/Pmall/RadioButtonOptions/View/Product/AttributeValue/Admin/

PHP Code:

namespace XLite\Module\Pmall\RadioButtonOptions\View\Product\AttributeValue\Admin;
/**
 * Attribute value (Radio)
 */
class Radio extends \XLite\View\Product\AttributeValue\Admin\AAdmin
{
    
/**
     * Get dir
     *
     * @return string
     */
    
protected function getDir()
    {
        return 
parent::getDir() . '/radio';
    }
    
/**
     * Return values
     *
     * @return array
     */
    
protected function getAttrValues()
    {
        
$values $this->getAttrValue();
        if (
$values) {
            
$result = array();
            foreach (
$values as $v) {
                
$result[$v->getId()] = $v;
            }
            unset(
$values);
        } else {
            
$result = array(null);
        }
        
$result['NEW_ID'] = null;
        return 
$result;
    }
    
/**
     * Get attribute type
     *
     * @return string
     */
    
protected function getAttributeType()
    {
        return \
XLite\Model\Attribute::TYPE_RADIO;
    }
    
/**
     * Return name of widget class
     *
     * @return string
     */
    
protected function getWidgetClass()
    {
        return 
$this->getAttribute() && !$this->getAttribute()->getProduct()
            ? 
'\XLite\View\FormField\Input\Text\AttributeOption'
            
'\XLite\View\FormField\Input\Text';
    }
    
/**
     * Return field value
     *
     * @param \XLite\Model\AttributeValue\AttributeValueSelect $attributeValue Attribute value
     *
     * @return mixed
     */
    
protected function getFieldValue($attributeValue)
    {
        return 
$attributeValue && $this->getAttribute() && $this->getAttribute()->getProduct()
            ? 
$attributeValue->getAttributeOption()->getName()
            : 
$attributeValue;
    }
    
/**
     * Get value style
     *
     * @param $id Id
     *
     * @return string
     */
    
protected function getValueStyle($id)
    {
        return 
'line clearfix '
            
. (is_int($id) ? 'value' 'new');
    }



qualiteam 03-25-2015 01:14 PM

Re: Class not found
 
Where and how do you use this class?

Quote:

Class '\XLite\View\Product\AttributeValue\Admin\Radio' not found

Quote:

include_once(/home/upflushi/www/var/run/classes/XLite/Model/AttributeValue/AttributeValueRadio.php

These error messages make me believe that there is an error in the class name somewhere either in your templates, or in other PHP classes that reference the \XLite\Module\Pmall\RadioButtonOptions\View\Produc t\AttributeValue\Admin\Radio class.

tony_sologubov 04-03-2015 05:14 AM

Re: Class not found
 
Hello Phil,

I feel you are referring to your new class as to
PHP Code:

\XLite\View\Product\AttributeValue\Admin\Radio 


but you should refer to it as to
PHP Code:

\XLite\Module\Pmall\RadioButtonOptions\View\Product\AttributeValue\Admin 


Please, let me know if it makes sense to you.

Tony


All times are GMT -8. The time now is 08:18 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.