How can I transfer the build folder to another site?
The problem is that the name of the database table prefix is sewn into the files and if I have a lot of sites I will have to manually change the data. Is it possible to automatically change the table names and prefixes?
For example:
abstract class BaseCategoriesPeer {
/** the default database name for this class */
const DATABASE_NAME = 'test';
/** the table name for this class */
const TABLE_NAME = 'test_123_categories';
For each new site I will have to change the data?
If I got it correctly, here's a possible solution:
You can check the directory in which your source file is, and make a switch to define a variable (let's say) $appStored.
Then in a class for database access definitions (it's more common than a table name schema that depends on the deploy site), you make another switch, this time switch ($appStored), and then define the names for each deploy configuration.
Related
I have this weird behaviour from Typo3 6.2 LTS.
In my extension I have a Model with a FileReference Property. This property has a vaule != 0. This value does exist in sys_file_reference table.
Not the weird magic happens. If I try to access this file, I do only get a nullvalue instead of a FileReference- / FileObject.
We already cleared our cache (server and browser) but nothing. It's still null.
I appreciate every kind of help!
Greetz, Paddaels
I remember it was always hard to make a 1:1 relation from a domain model to a FileReference. I suggest you to use existing patterns and work with a ObjectStorage for that purpose.
You can copy the neccessary TCA from the existing tca of the tt_content table (field image for example). The Property annotation should look like:
/**
* #var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\Extension\Domain\Model\FileReference>
* #lazy
* #cascade remove
*/
protected $propName;
Of course you have to create the FileReference Model in your own namespace. But you can extend the Extbase basemodel, so you dont have to write any methods.
To map your model to the sys_file_reference table you have to add some typoscript.
For that purpose create a ext_typoscript_setup.txt in your extensions folder and insert the following code (adjust namespace and modelname)
config.tx_extbase.persistence.classes {
Vendor\Extension\Domain\Model\FileReference.mapping {
tableName = sys_file_reference
}
}
After clearing the caches in the install tool (and making database migrations of course) it should work.
Explanations:
#lazy: Typo3 wont fetch all references at once, only if the property is accessed.
#cascade remove: Extbase will delete all sys_file_reference records related to your domain model once the model is deleted.
I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically. I've found that the urls of every product are in the enterprise_url_rewrite table, request path field.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Good afternoon! Let's break this down:
I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically
Yes - you can create URL rewrites dynamically using the Magento models that represent the database table you've identified already:
/** #var Enterprise_UrlRewrite_Model_Redirect $rewrite */
$rewrite = Mage::getSingleton('enterprise_urlrewrite/redirect');
// Create new record or load the existing one
$rewrite->loadByRequestPath($requestUrl, $store->getId());
$rewrite
->setStoreId($store->getId()) // define which store the rewrite should be
->setOptions(null) // specify any rewrite/redirect/custom options
->setRequestPath($requestUrl) // specify the request URL
->setIdentifier($requestUrl)
->setTargetPath($targetPath) // specify the redirect target
->setEntityType(Mage_Core_Model_Url_Rewrite::TYPE_CUSTOM)
->setDescription('Add a comment if you want to');
$rewrite->save();
This will attempt to load an existing URL rewrite/redirect by the $requestUrl and will return an empty model if it was not found which you can embellish with your data and save.
The "options" define whether it's a temporary or permanent redirect (302 vs 301).
More information here via the Magento EE user guide.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Don't worry about it. The (modern) Magento database has table triggers wherever records need to be indexed, and will detect creations, updated and deletions on those tables. The indexers will detect that change need to be made and will make them for you as required.
If you're seeing URL rewrites disappearing it's most likely because you've been adding them directly to the index table with SQL, so the table is rewritten whenever the indexer runs. To avoid this use the model as noted above and everything will be saved into the correct location and indexed properly.
I am working in a project that has a large postgreSQL database. The previous project was developed in Java from scratch. We are now developing that in Laravel. The previous system had user management system similar to Zizaco/entrust. So, we used in our system as well. The previous table had module table instead of permission table used in entrust. We have already configured that by changing the table name in config/entrust.php. However, the previous system has permission_name instead of name field used in entrust. How do I config entrust to use the unique permission_name instead of name field.
I am looking for a solution, so that we don't have to change in the sources of entrust because then upgrading it would break the system. Can it be configured in the model?
The Entrust package is hardcoded to use the name attribute, so there is no configuration value or anything to change that. However, one thing you can attempt is to define an accessor and mutator for the name attribute.
In your App\Permission model, define the following functions:
class Permission extends Model {
// accessor
public function getNameAttribute($value) {
return $this->permission_name;
}
// mutator
public function setNameAttribute($value) {
$this->attributes['permission_name'] = $value;
}
}
Documentation for accessors and mutators: http://laravel.com/docs/5.0/eloquent#accessors-and-mutators
I just created a new grails domain class on a project I just started working on. I know the datasources are setup correctly since we already have a bunch of domain classes that are updating to the database just fine.
The error I get:
Caused by BatchUpdateException: ORA-00942: table or view does not exist
I tried running DBMUpdate but that also did not create the table.
Is there something I'm missing with creating domain classes? Do I need to change something in the changelog ? Any advise would be helpful!
The easiest thing would be to add dbCreate = "update" to your DataSource.groovy. A better thing would be to use the database-migrations plugin for your app.
Regarding manually creating tables, the convention grails following by default is to underscore camelcase. For example, given the following domains:
class User {
String firstName
String lastName
static hasMany = [addresses: Address]
}
class Address {
static belongsTo = [user: User]
}
You would end up with the following tables:
user
---------
id
version
first_name
last_name
---------
address
---------
id
version
user_id
---------
Try running...
grails export-schema
This will uses Hibernate's SchemaExport tool to generate DDL or export the schema for the entire database. From that file, you can grab the lines for the missing table.
Check out the Grails Quick Reference for more details on the command.
I've build an extension with a table named after the extension.
Now I want to change the tablename and add '_items' behind it.
I changed the name in all de classes where I could find the name but to no result.
Im surely missing something but not sure what. Any help would be appreciated as where to define the table name
Within the config.xml you can change what's inside the tags to whatever table name you want it to point to. Just don't change the entity name (which is and in your case). You should not change anything in any of the classes. That's the beauty of the Magento architecture your classes do not depend on the table schema (ie table names).