Questions around the TYPO3 integration and plugins as well as Flow and NeosCMS
Forum rules: Always add your TYPO3/Flow, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5327 by mantik
02 Jan 2018, 08:41
Hmm the name attribute i've earlier deleted for some tests but forgott to paste it back.
Now the getter working. but the setter not... it dosent save
(i just need to update because on create this field can be empty)

and there is a problem with this method from your example:
Code: Select all 

    public function getSearchAttributes( $withsub = true )

    {

        $list = parent::getSearchAttributes( $withsub );

        foreach( $list as $key => $fields ) {

            $list[$key] = new \Aimeos\MW\Criteria\Attribute\Standard( $fields );

        }

        return $list;

    }


Uncaught TYPO3 Exception
Argument 1 passed to Aimeos\MW\Criteria\Attribute\Standard::__construct() must be of the type array, object given, called

when i take this method from parent class:
Code: Select all
   public function getSearchAttributes( $withsub = true ){
        $path = 'mshop/order/manager/base/submanagers';
        $default = array( 'address', 'coupon', 'product', 'service' );
        return $this->getSearchAttributesBase( $this->searchConfig, $path, $default, $withsub );
   }

i got: Fehler Invalid name "order.base.id"
#5331 by mantik
03 Jan 2018, 12:24
ok i've solve it by take the second script and add the whole searchConfig-Array from the whole class.
Now just the problem with the saving.

i can read a value from the database but not update...

and i got a new problem. since i activate my own order.bas.manager my basket does not work anymore.
Code: Select allCall to a member function getSite() on null

Error thrown in file
/var/www/vhosts/domain.ch/httpdocs/typo3conf/ext/aimeos/Resources/Private/Extensions/ai-controller-frontend/controller/frontend/src/Controller/Frontend/Basket/Base.php in line 182.

28 Aimeos\Controller\Frontend\Basket\Base::checkLocale("default")...


can please someone help me. i stuck over three days on this problems but got every time just one answer the day... and the last one was just a half....
#5338 by aimeos
04 Jan 2018, 10:33
mantik wrote:i can read a value from the database but not update...


It's still for the customer manager? Did you copy the saveItem() method of the TYPO3 customer manager and use bind() to add your new property? Did you adapt the insert/update SQL in the configuration?

mantik wrote:and i got a new problem. since i activate my own order.bas.manager my basket does not work anymore.
Code: Select allCall to a member function getSite() on null


Did you extend your class from the \Aimeos\MShop\Order\Base\Standard class?

mantik wrote:can please someone help me. i stuck over three days on this problems but got every time just one answer the day... and the last one was just a half....


We are all doing this in our spare time. If you need professional support, please ask the Aimeos company for help:
https://aimeos.com/support/
#5340 by mantik
04 Jan 2018, 10:55
its not about the customer manager i extend the oder base manager. and i do all that what you write.
here is my whole code so you can check it

typo3conf/ext/my_shop/Resources/Private/Extensions/my_shop/lib/custom/config/mshop/order.php
Code: Select all<?php
return array(
   'manager' => array(
      'base' => array(
          'name'=>'Myorder',
         'standard' => array(
            'insert' => array(
               'ansi' => '
                  INSERT INTO "mshop_order_base" (
                     "customerid", "sitecode", "langid", "currencyid",
                     "price", "costs", "rebate", "tax", "taxflag", "comment",
                     "status", "mtime", "editor", "myid", "siteid", "ctime"
                  ) VALUES (
                     ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
                  )
               '
            ),
            'update' => array(
               'ansi' => '
                  UPDATE "mshop_order_base"
                  SET "customerid" = ?, "sitecode" = ?, "langid" = ?, "currencyid" = ?,
                     "price" = ?, "costs" = ?, "rebate" = ?, "tax" = ?, "taxflag" = ?,
                     "comment" = ?, "status" = ?, "mtime" = ?, "editor" = ?,"myid" = ?
                  WHERE "siteid" = ? AND "id" = ?
               '
            ),
            'search' => array(
               'ansi' => '
                  SELECT mordba."id" AS "order.base.id", mordba."siteid" AS "order.base.siteid",
                     mordba."sitecode" AS "order.base.sitecode", mordba."customerid" AS "order.base.customerid",
                     mordba."langid" AS "order.base.languageid", mordba."currencyid" AS "order.base.currencyid",
                     mordba."price" AS "order.base.price", mordba."costs" AS "order.base.costs",
                     mordba."rebate" AS "order.base.rebate", mordba."tax" AS "order.base.taxvalue",
                     mordba."taxflag" AS "order.base.taxflag", mordba."comment" AS "order.base.comment",
                     mordba."status" AS "order.base.status", mordba."mtime" AS "order.base.mtime",
                     mordba."editor" AS "order.base.editor", mordba."ctime" AS "order.base.ctime",
                     mordba."myid" AS "order.base.myid"
                  FROM "mshop_order_base" AS mordba
                  :joins
                  WHERE :cond
                  GROUP BY mordba."id", mordba."siteid", mordba."sitecode", mordba."customerid",
                     mordba."langid", mordba."currencyid", mordba."price", mordba."costs",
                     mordba."rebate", mordba."tax", mordba."taxflag", mordba."comment", mordba."status",
                     mordba."mtime", mordba."editor", mordba."ctime" /*-columns*/ , :columns /*columns-*/
                  /*-orderby*/ ORDER BY :order /*orderby-*/
                  LIMIT :size OFFSET :start
               '
            ),
            'newid' => array(
               'db2' => 'SELECT IDENTITY_VAL_LOCAL()',
               'mysql' => 'SELECT LAST_INSERT_ID()',
               'oracle' => 'SELECT mshop_order_base_seq.CURRVAL FROM DUAL',
               'pgsql' => 'SELECT lastval()',
               'sqlite' => 'SELECT last_insert_rowid()',
               'sqlsrv' => 'SELECT SCOPE_IDENTITY()',
               'sqlanywhere' => 'SELECT @@IDENTITY',
            ),
         )
      )
   )
);
   ?>


typo3conf/ext/my_shop/Resources/Private/Extensions/my_shop/lib/custom/src/MShop/Order/Item/
Base/Myorder.php
Code: Select all<?php
namespace Aimeos\MShop\Order\Item\Base;

class Myorder extends Standard{

   private $price;
   private $locale;
   private $values;
   private $modified = false;

   /**
    * Initializes the shopping cart.
    *
    * @param \Aimeos\MShop\Price\Item\Iface $price Default price of the basket (usually 0.00)
    * @param \Aimeos\MShop\Locale\Item\Iface $locale Locale item containing the site, language and currency
    * @param array $values Associative list of key/value pairs containing, e.g. the order or user ID
    * @param array $products List of ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface
    * @param array $addresses List of order addresses implementing \Aimeos\MShop\Order\Item\Base\Address\Iface
    * @param array $services List of order services implementing \Aimeos\MShop\Order\Item\Base\Service\Iface
    * @param array $coupons Associative list of coupon codes as keys and ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface as values
    */
   public function __construct(\Aimeos\MShop\Price\Item\Iface $price, \Aimeos\MShop\Locale\Item\Iface $locale,
      array $values = [], array $products = [], array $addresses = [],
      array $services = [], array $coupons = [] )
   {
      parent::__construct( $price, $locale, $values, $products, $addresses, $services, $coupons );
      $this->price = $price;
      $this->locale = $locale;
      $this->values = $values;
   }

   public function getMyid(){
      if( isset( $this->values['order.base.myid'] ) ) {
         return (string) $this->values['order.base.myid'];
      }
      return 0;
   }

   public function setMyid( $myid ){
      if( (string) $myid !== $this->getMyid() ){
         $this->values['order.base.myid'] = (string) $myid;
         $this->modified = true;
      }
      return $this;
   }

   public function fromArray( array $list ){
      $unknown = [];
      $list = parent::fromArray( $list );

      foreach( $list as $key => $value )
      {
         switch( $key ){
            case 'order.base.myid': $this->setMyid( $value ); break;
            default: $unknown[$key] = $value;
         }
      }
      return $unknown;
   }

   public function toArray( $private = false ){
      $list = parent::toArray( $private );

      if( $private === true ) {
         $list['order.base.myid'] = $this->getMyid();
      }



      return $list;
   }

}


typo3conf/ext/my_shop/Resources/Private/Extensions/my_shop/lib/custom/src/MShop/Order/Manager/
Base/Myorder.php
Code: Select all<?php
namespace Aimeos\MShop\Order\Manager\Base;

class Myorder extends Standard {
   private $searchConfig = array(
      'order.base.myid' => array(
         'code' => 'order.base.myid',
         'internalcode' => 'mordba."myid"',
         'label' => 'My ID',
         'type' => 'string',
         'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR
      )
   );

   /**
    * Adds or updates an order base item in the storage.
    *
    * @param \Aimeos\MShop\Common\Item\Iface $item Order base object (sub-items are not saved)
    * @param boolean $fetch True if the new ID should be returned in the item
    * @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID
    */
   public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
   {
      $iface = '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface';
      if( !( $item instanceof $iface ) ) {
         throw new \Aimeos\MShop\Order\Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
      }

      if( !$item->isModified() ) {
         return $item;
      }

      $context = $this->getContext();
      $dbm = $context->getDatabaseManager();
      $dbname = $this->getResourceName();
      $conn = $dbm->acquire( $dbname );

      try {
         $id = $item->getId();
         $date = date( 'Y-m-d H:i:s' );

         if( $id === null ){
            $path = 'mshop/order/manager/base/standard/insert';
         } else {
            $path = 'mshop/order/manager/base/standard/update';
         }

         $priceItem = $item->getPrice();
         $localeItem = $context->getLocale();
         $stmt = $this->getCachedStatement( $conn, $path );

         $stmt->bind( 1, $item->getCustomerId() );
         $stmt->bind( 2, $localeItem->getSite()->getCode() );
         $stmt->bind( 3, $item->getLocale()->getLanguageId() );
         $stmt->bind( 4, $priceItem->getCurrencyId() );
         $stmt->bind( 5, $priceItem->getValue() );
         $stmt->bind( 6, $priceItem->getCosts() );
         $stmt->bind( 7, $priceItem->getRebate() );
         $stmt->bind( 8, $priceItem->getTaxValue() );
         $stmt->bind( 9, $priceItem->getTaxFlag(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
         $stmt->bind( 10, $item->getComment() );
         $stmt->bind( 11, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
         $stmt->bind( 12, $date ); // mtime
         $stmt->bind( 13, $context->getEditor() );
            $stmt->bind( 14, $item->getMyid() );
            $stmt->bind( 15, $localeItem->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );

         if( $id !== null ) {
            $stmt->bind( 16, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
            $item->setId( $id );
         } else {
            $stmt->bind( 16, $date ); // ctime
         }



         $stmt->execute()->finish();

         if( $id === null && $fetch === true ){
            $path = 'mshop/order/manager/base/standard/newid';
            $item->setId( $this->newId( $conn, $path ) );
         }

         $dbm->release( $conn, $dbname );
      }

      catch( \Exception $e ){
         $dbm->release( $conn, $dbname );
         throw $e;
      }

      return $item;
   }

   public function getSearchAttributes( $withsub = true ) {

      $list = parent::getSearchAttributes( $withsub );

      foreach( $this->searchConfig as $key => $fields ) {
         $list[$key] = new \Aimeos\MW\Criteria\Attribute\Standard( $fields );
      }

      return $list;

   }

   protected function createItemBase( \Aimeos\MShop\Price\Item\Iface $price, \Aimeos\MShop\Locale\Item\Iface $locale,
      array $values = [], array $products = [], array $addresses = [],
      array $services = [], array $coupons = [] ){

      return new \Aimeos\MShop\Order\Item\Base\Myorder($price, $locale, $values, $products, $addresses, $services, $coupons);

   }


}
?>


So what works:
- i can see the field in the Backendmodule by order and i can read the values if i post it direct in the database. so getter works
- i can filter
- i can sort

whats wrong:
- i can open an order and see the values of order.base.myid BUT if i change something after reload the old values stays.
in frontend: as soon i put something in the basket (why basket i extend the order?) i got a php expetion: Call to a member function getSite() on null
in
#5347 by aimeos
04 Jan 2018, 22:02
mantik wrote:- i can open an order and see the values of order.base.myid BUT if i change something after reload the old values stays.


I would have a look into the JQAdm template if your new propery is passed correctly as "order.base.myid"

mantik wrote:in frontend: as soon i put something in the basket (why basket i extend the order?) i got a php expetion: Call to a member function getSite() on null


The basket is only a order that's not yet stored. Looks like the locale item is not available in your order base object
#5349 by mantik
05 Jan 2018, 09:02
aimeos wrote:
mantik wrote:- i can open an order and see the values of order.base.myid BUT if i change something after reload the old values stays.


I would have a look into the JQAdm template if your new propery is passed correctly as "order.base.myid"

mantik wrote:in frontend: as soon i put something in the basket (why basket i extend the order?) i got a php expetion: Call to a member function getSite() on null


The basket is only a order that's not yet stored. Looks like the locale item is not available in your order base object


very great answer!! i know whats the problem but my question is whats the solution.
this is the last time i use aimeos shop for a project.

Your code is buggy and after each update i have to scare that all works (like i say in other topics) your documentation is uncomplete (the problem why my property wasent save is because i dont add the isModified() Method from the parent to my class - but where is that in your documentation? now saving works.).

guys i understand that your support here is for free but if you promise us a very stable, scalable,flexible, etc shop on your website then i think that you have some responbility for the community.

i mean i buy for this project the customergroup-extension (end also in this commercial product was a bug who delete in my category modul the product tab) and if we can have together a great system then you will also profit. but if you promise me something, redirect me to some uncomplete and wrong documentaion and then if it dosent work (and i cant waite for a task that takes 1-2 hours a week for trying, testing, debugging, waiting for answers) then you say to me if you dont like it so pay me....

hmm i think thats not ok...

we have also responbility to our clients, we have timelines and wee need here a professionell workflow.

aimeos is a good shop and mostly i like it but because some unprofessional workflow i have on this project work few days for free and thats not ok...

i like more to say to my clients ok there is nothing in typo3 for your requirements so take an other solution like magento or let it be.
#5353 by aimeos
05 Jan 2018, 12:53
First of all, we (the maintainers and contributors) would like to emphasize that Aimeos is a true Open Source project supported by enthusiasts who first of all use the Aimeos components in their own projects. The Open Source project doesn't belong to Norbert's Aimeos company which only offers paid support and a few commercial extensions. Thus, helping others is something we do for free and most of the time we get nothing back but a "Thank you" from the people we are supporting. So we are all the community and it's not "you" and "us"!

The Open Source project lives from contributions (features, bugfixes, documentation) and if you find something that is wrong, fix it and make a pull request or tell us if there's something in the documentation that should be added. The Aimeos communitiy is not as big as the Magento one, so you MAY get a faster response for Magento questions. But you won't get ANY support from the Magento company for their community edition!

We appologize that we haven't seen the problem of the missing salutation translations in version 17.10.2 but after you've mentioned that, we build a fixed version immediately. If there's anything wrong in an extension you've bought from the Aimeos company, we are neither involved nor responsible for that. But I know Norbert very well and he's also very helpful and fixes problems immediately.

All members of the community have a responsibility for our own projects and clients. But if you expect enterprise grade support from other community members for free, then you have definitively a wrong attitude towards any community! First of all, you have to debug problems in your own code yourself - or pay the Aimeos company to have a look into it and debug it for you. Based on the code you've posted, we can only give hints where you should have a look if it's not something obvious.

This brings us back to your problem: Your code looks OK and I guess the problem occurs before. Another possibility would be a PHP bug due to the fact that the "$locale" property is named the same in your item class as in the base class. We had this already before with "$values" (therefore it's named "$bdata" in base classes) and filed a bug in the PHP issue tracker.

Tom
#5355 by nos3
05 Jan 2018, 15:16
Hi mantik

Sorry that the default config of the ai-customergroups extension removed the catalog product panel in your installation.
I think that Tom, Andy and all the others do a damn good job even if they can't help everybody immediately!

BR, Norbert